Skip to content

Commit 8c33aa3

Browse files
committed
Improve not found error handling for the covert art client;
1 parent 75abbe7 commit 8c33aa3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

lib/coverartarchive-api.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,23 @@ export class CoverArtArchiveApi {
3737
Accept: "application/json"
3838
}
3939
});
40-
return response.json();
40+
41+
try {
42+
const j = await response.json();
43+
return j;
44+
} catch (e) {
45+
if (response.status === 404) {
46+
return {
47+
"error": "Not Found",
48+
"help": "For usage, please see: https://musicbrainz.org/development/mmd"
49+
}
50+
} else {
51+
return {
52+
"error": (e as Error).message,
53+
"help": "For usage, please see: https://musicbrainz.org/development/mmd"
54+
}
55+
}
56+
}
4157
}
4258

4359
/**

0 commit comments

Comments
 (0)