Hiding syntax errors when API is down.

This commit is contained in:
Roland 2024-12-18 17:32:00 -07:00
parent 7c147747f1
commit 74a1486f0e
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
4 changed files with 21 additions and 7 deletions

View file

@ -114,7 +114,10 @@ export function useEventsInterval() {
setEvents(response['events']);
} catch (e) {
setEvents(null);
console.error(e);
// Ignore SyntaxError because they happen when the API is down.
if (!(e instanceof SyntaxError)) {
console.error(e);
}
}
}

View file

@ -48,7 +48,10 @@ export function useTags() {
} catch (e) {
setTags(undefined);
setTagNames(undefined);
console.error(e);
// Ignore SyntaxError because they happen when the API is down.
if (!(e instanceof SyntaxError)) {
console.error(e);
}
}
}

View file

@ -51,8 +51,10 @@ async function apiCall(url, method, body, ms = 60_000) {
}
return response;
} catch (e) {
// Timeout, or some other exception.
console.error(e);
// Ignore SyntaxError because they happen when the API is down.
if (!(e instanceof SyntaxError)) {
console.error(e);
}
throw e;
}
}

View file

@ -18,8 +18,8 @@ import {
getStatus,
getVideo,
getVideosStatistics,
postImportConfig,
postDumpConfig,
postImportConfig,
saveSettings,
searchArchives,
searchChannels,
@ -705,7 +705,10 @@ export const useConfigs = () => {
setConfigs(data['configs']);
console.debug('fetching configs successful');
} catch (e) {
console.error(e);
// Ignore SyntaxError because they happen when the API is down.
if (!(e instanceof SyntaxError)) {
console.error(e);
}
setConfigs(undefined);
} finally {
setLoading(false);
@ -840,7 +843,10 @@ export const useStatus = () => {
const s = await getStatus();
setStatus(s);
} catch (e) {
console.error(e);
// Ignore SyntaxError because they happen when the API is down.
if (!(e instanceof SyntaxError)) {
console.error(e);
}
}
}