Skip to content

Commit 552e921

Browse files
committed
Fixed bug when API key is missing
1 parent 265bf10 commit 552e921

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/api/apis/MobyGamesAPI.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export class MobyGamesAPI extends APIModel {
2222
console.log(`MDB | api "${this.apiName}" queried by Title`);
2323

2424
if (!this.plugin.settings.MobyGamesKey) {
25-
throw Error(`MDB | API key for ${this.apiName} missing.`);
25+
console.error(Error(`MDB | API key for ${this.apiName} missing.`));
26+
return [];
2627
}
2728

2829
const searchUrl = `${this.apiUrl}/games?title=${encodeURIComponent(title)}&api_key=${this.plugin.settings.MobyGamesKey}`;
@@ -65,7 +66,7 @@ export class MobyGamesAPI extends APIModel {
6566
console.log(`MDB | api "${this.apiName}" queried by ID`);
6667

6768
if (!this.plugin.settings.MobyGamesKey) {
68-
throw Error(`MDB | API key for ${this.apiName} missing.`);
69+
console.log(Error(`MDB | API key for ${this.apiName} missing.`));
6970
}
7071

7172
const searchUrl = `${this.apiUrl}/games?id=${encodeURIComponent(id)}&api_key=${this.plugin.settings.MobyGamesKey}`;

src/api/apis/OMDbAPI.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class OMDbAPI extends APIModel {
2929
console.log(`MDB | api "${this.apiName}" queried by Title`);
3030

3131
if (!this.plugin.settings.OMDbKey) {
32-
throw Error(`MDB | API key for ${this.apiName} missing.`);
32+
console.error(Error(`MDB | API key for ${this.apiName} missing.`));
33+
return [];
3334
}
3435

3536
const searchUrl = `https://www.omdbapi.com/?s=${encodeURIComponent(title)}&apikey=${this.plugin.settings.OMDbKey}`;
@@ -222,4 +223,4 @@ export class OMDbAPI extends APIModel {
222223

223224
return;
224225
}
225-
}
226+
}

0 commit comments

Comments
 (0)