Fix report issue

This commit is contained in:
Arnaud 2024-09-27 19:19:02 +02:00
parent 57887a5577
commit bc70ff1397
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663

View File

@ -1,4 +1,4 @@
import { CodexError, SafeValue } from "@codex-storage/sdk-js";
import { SafeValue } from "@codex-storage/sdk-js";
import * as Sentry from "@sentry/browser";
import { isCodexOnline } from "../components/NodeIndicator/NodeIndicator";
@ -21,15 +21,18 @@ const getLogLevel = () => {
export const Promises = {
rejectOnError: <T>(safe: SafeValue<T>, report = true) => {
if (safe.error && report) {
Sentry.captureException(safe.data, {
extra: {
code: safe.data.code,
errors: safe.data.errors,
sourceStack: safe.data.sourceStack,
level: getLogLevel(),
},
});
if (safe.error) {
if (report) {
Sentry.captureException(safe.data, {
extra: {
code: safe.data.code,
errors: safe.data.errors,
sourceStack: safe.data.sourceStack,
level: getLogLevel(),
},
});
}
return Promise.reject(safe.data);
}