Added notice when an API key is missing

This commit is contained in:
ltctceplrm 2024-08-22 15:51:34 +02:00
parent 08ca5e122f
commit 6234677bde
2 changed files with 6 additions and 0 deletions

View file

@ -1,4 +1,5 @@
import { APIModel } from '../APIModel';
import { Notice } from 'obsidian';
import { MediaTypeModel } from '../../models/MediaTypeModel';
import { MovieModel } from '../../models/MovieModel';
import MediaDbPlugin from '../../main';
@ -30,6 +31,7 @@ export class OMDbAPI extends APIModel {
if (!this.plugin.settings.OMDbKey) {
console.error(new Error(`MDB | API key for ${this.apiName} missing.`));
new Notice(`MediaDB | API key for ${this.apiName} missing.`);
return [];
}
@ -108,6 +110,7 @@ export class OMDbAPI extends APIModel {
console.log(`MDB | api "${this.apiName}" queried by ID`);
if (!this.plugin.settings.OMDbKey) {
new Notice(`MediaDB | API key for ${this.apiName} missing.`);
throw Error(`MDB | API key for ${this.apiName} missing.`);
}