better error handling

This commit is contained in:
Lena Brueder 2025-06-09 14:45:38 +02:00
parent 7b22e0e562
commit 60b251f103
7 changed files with 77 additions and 36 deletions

View file

@ -258,7 +258,7 @@ export class PocketbookCloudLoginClient {
// use first defined response, if any
const login_response = login_responses.filter(response => response.result).first();
if (!login_response) {
throw new Error('Could not log in to Pocketbook Cloud');
throw new Error('Could not log in to Pocketbook Cloud - check if username / password are correct.');
}
this.access_token = login_response.result.access_token;

View file

@ -64,12 +64,17 @@ export class PocketbookCloudHighlightsImporterSettingTab extends PluginSettingTa
null,
new Date()
);
api_client.login();
try {
await api_client.login();
} catch (error) {
new Notice(`❌ Error logging in: ${error.message}`);
return;
}
this.plugin.settings.access_token = await api_client.getAccessToken();
this.plugin.settings.access_token_valid_until = api_client.getAccessTokenValidUntil();
this.plugin.settings.refresh_token = await api_client.getRefreshToken();
this.plugin.saveSettings();
await this.plugin.saveSettings();
shop_name_text_field.setValue(this.plugin.settings.shop_name);

View file

@ -1,5 +1,4 @@
[
"dataview",
"obsidian-pocketbook-cloud-highlight-importer",
"pocketbook-cloud-highlight-importer"
]

View file

@ -1,20 +1,32 @@
[
"file-explorer",
"global-search",
"switcher",
"graph",
"backlink",
"canvas",
"outgoing-link",
"tag-pane",
"page-preview",
"daily-notes",
"templates",
"note-composer",
"command-palette",
"editor-status",
"bookmarks",
"outline",
"word-count",
"file-recovery"
]
{
"file-explorer": true,
"global-search": true,
"switcher": true,
"graph": true,
"backlink": true,
"canvas": true,
"outgoing-link": true,
"tag-pane": true,
"page-preview": true,
"daily-notes": true,
"templates": true,
"note-composer": true,
"command-palette": true,
"slash-command": false,
"editor-status": true,
"starred": true,
"markdown-importer": false,
"zk-prefixer": false,
"random-note": false,
"outline": true,
"word-count": true,
"slides": false,
"audio-recorder": false,
"workspaces": false,
"file-recovery": true,
"publish": false,
"sync": false,
"bookmarks": true,
"properties": false,
"webviewer": false
}

View file

@ -1,7 +1,7 @@
{
"id": "pocketbook-cloud-highlight-importer",
"name": "Pocketbook Cloud Highlight Importer",
"version": "0.1.5",
"version": "0.1.6",
"minAppVersion": "1.1.16",
"description": "Imports notes and highlights from your Pocketbook Cloud account.",
"author": "Lena Brüder",

View file

@ -12,7 +12,9 @@
"type": "leaf",
"state": {
"type": "empty",
"state": {}
"state": {},
"icon": "lucide-file",
"title": "New tab"
}
}
]
@ -34,8 +36,11 @@
"state": {
"type": "file-explorer",
"state": {
"sortOrder": "alphabetical"
}
"sortOrder": "alphabetical",
"autoReveal": false
},
"icon": "lucide-folder-closed",
"title": "Files"
}
},
{
@ -50,7 +55,9 @@
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical"
}
},
"icon": "lucide-search",
"title": "Search"
}
},
{
@ -58,7 +65,9 @@
"type": "leaf",
"state": {
"type": "starred",
"state": {}
"state": {},
"icon": "lucide-file",
"title": "Plugin no longer active"
}
},
{
@ -66,7 +75,9 @@
"type": "leaf",
"state": {
"type": "bookmarks",
"state": {}
"state": {},
"icon": "lucide-bookmark",
"title": "Bookmarks"
}
}
]
@ -96,7 +107,9 @@
"searchQuery": "",
"backlinkCollapsed": false,
"unlinkedCollapsed": true
}
},
"icon": "links-coming-in",
"title": "Backlinks"
}
},
{
@ -107,7 +120,9 @@
"state": {
"linksCollapsed": false,
"unlinkedCollapsed": true
}
},
"icon": "links-going-out",
"title": "Outgoing links"
}
},
{
@ -117,8 +132,12 @@
"type": "tag",
"state": {
"sortOrder": "frequency",
"useHierarchy": true
}
"useHierarchy": true,
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-tags",
"title": "Tags"
}
},
{
@ -126,7 +145,13 @@
"type": "leaf",
"state": {
"type": "outline",
"state": {}
"state": {
"followCursor": false,
"showSearch": false,
"searchQuery": ""
},
"icon": "lucide-list",
"title": "Outline"
}
}
]