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:
parent
afefaf410e
commit
1b97a47ef6
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user