Do not report Gateway error

This commit is contained in:
Arnaud 2024-10-14 18:44:50 +02:00
parent 3b0734d1ba
commit 88055057a2
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
1 changed files with 5 additions and 19 deletions

View File

@ -1,32 +1,18 @@
import * as Sentry from "@sentry/browser";
import { isCodexOnline } from "../components/NodeIndicator/NodeIndicator";
import { CodexError } from "@codex-storage/sdk-js";
// It would be preferable to completely ignore the error
// when the node is not connected. However, during the
// initial load, we lack this information until the
// SPR response is completed. In the meantime, other
// requests may be initiated, so if the node is not
// connected, we should set the level to 'log'.
const getLogLevel = () => {
switch (isCodexOnline) {
case true:
return "error";
case null:
return "info";
case false:
return "log";
}
};
export const Errors = {
report(safe: { error: true, data: CodexError }) {
if (safe.data.code === 502) {
// Ignore Gateway error
return
}
Sentry.captureException(safe.data, {
extra: {
code: safe.data.code,
errors: safe.data.errors,
sourceStack: safe.data.sourceStack,
level: getLogLevel(),
},
});
}