2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-12 13:47:49 +00:00

fix: correctly handle api errors

This commit is contained in:
Vjacheslav Trushkin 2022-11-29 11:00:44 +02:00
parent afefaf410e
commit 1b97a47ef6
2 changed files with 6 additions and 7 deletions

View File

@ -93,14 +93,9 @@ function loadNewIcons(storage: IconStorageWithAPI, icons: string[]): void {
// Prepare parameters and run queries
const params = api.prepare(provider, prefix, icons);
params.forEach((item) => {
sendAPIQuery(provider, item, (data, error) => {
sendAPIQuery(provider, item, (data) => {
// Check for error
if (typeof data !== 'object') {
if (error !== 404) {
// Do not handle error unless it is 404
return;
}
// Not found: mark as missing
item.icons.forEach((name) => {
storage.missing.add(name);

View File

@ -206,7 +206,11 @@ const send: IconifyAPISendQuery = (
if (typeof data !== 'object' || data === null) {
setTimeout(() => {
// Complete on next tick to get out of try...catch
callback('next', defaultError);
if (data === 404) {
callback('abort', data);
} else {
callback('next', defaultError);
}
});
return;
}