Skip to content

Commit 2dc3790

Browse files
committed
Added more notices when an API errors out
So users know what went wrong without going to the console
1 parent 6234677 commit 2dc3790

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/api/apis/MobyGamesAPI.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export class MobyGamesAPI extends APIModel {
7979
console.debug(fetchData);
8080

8181
if (fetchData.status !== 200) {
82+
new Notice(`MDB | Received status code ${fetchData.status} from ${this.apiName}.`);
8283
throw Error(`MDB | Received status code ${fetchData.status} from ${this.apiName}.`);
8384
}
8485

src/api/apis/OMDbAPI.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,19 @@ export class OMDbAPI extends APIModel {
118118
const fetchData = await fetch(searchUrl);
119119

120120
if (fetchData.status === 401) {
121+
new Notice(`MDB | Authentication for ${this.apiName} failed. Check the API key.`);
121122
throw Error(`MDB | Authentication for ${this.apiName} failed. Check the API key.`);
122123
}
123124
if (fetchData.status !== 200) {
125+
new Notice(`MDB | Received status code ${fetchData.status} from ${this.apiName}.`);
124126
throw Error(`MDB | Received status code ${fetchData.status} from ${this.apiName}.`);
125127
}
126128

127129
const result = await fetchData.json();
128130
// console.debug(result);
129131

130132
if (result.Response === 'False') {
133+
new Notice(`MDB | Received error from ${this.apiName}: ${result.Error}`);
131134
throw Error(`MDB | Received error from ${this.apiName}: ${result.Error}`);
132135
}
133136

0 commit comments

Comments
 (0)