Added simple error handling during login

This commit is contained in:
Robert Meissner 2025-06-08 14:57:39 +02:00
parent d2d24f7918
commit be1626d961

View file

@ -1,4 +1,4 @@
import { requestUrl } from 'obsidian';
import { Notice, requestUrl } from 'obsidian';
import PocketbookCloudHighlightsImporterPlugin from './main';
export interface PocketbookCloudBookCover {
@ -188,6 +188,19 @@ export class PocketbookCloudLoginClient {
) {}
async login() {
// Validate required parameters
if (!this.username || this.username.trim() === '') {
new Notice('❌ Error: Username is required and cannot be empty');
}
if (!this.client_id || this.client_id.trim() === '') {
new Notice('❌ Error: Client ID is required and cannot be empty');
}
if (!this.client_secret || this.client_secret.trim() === '') {
new Notice('❌ Error: Client secret is required and cannot be empty');
}
const shops: PocketbookCloudShopInfo[] = await fetch(
'https://cloud.pocketbook.digital/api/v1.0/auth/login?' +
new URLSearchParams({