From 3966aa929608520869486043e633a32156d93c19 Mon Sep 17 00:00:00 2001 From: Rodrigo Branas Date: Thu, 27 Jun 2024 00:13:07 -0300 Subject: [PATCH] fix: handling error format to improve further sentry identification (#1397) - Closes #1381 Improved error handling to avoid loose information before send it to sentry Including location informations for better understanding the possible causes of error --- .changeset/red-apes-refuse.md | 5 +++++ packages/app/src/systems/Error/utils/parseFuelError.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/red-apes-refuse.md diff --git a/.changeset/red-apes-refuse.md b/.changeset/red-apes-refuse.md new file mode 100644 index 000000000..56e255b14 --- /dev/null +++ b/.changeset/red-apes-refuse.md @@ -0,0 +1,5 @@ +--- +"fuels-wallet": minor +--- + +Improved error handling and including location informations to support better understanding about the causes of erros diff --git a/packages/app/src/systems/Error/utils/parseFuelError.ts b/packages/app/src/systems/Error/utils/parseFuelError.ts index 8dee0afa3..f4c41c16b 100644 --- a/packages/app/src/systems/Error/utils/parseFuelError.ts +++ b/packages/app/src/systems/Error/utils/parseFuelError.ts @@ -7,17 +7,19 @@ export function parseFuelError(error: any): FuelWalletError { ...error, timestamp: Date.now(), id: createUUID(), + location: window ? window.location.href : '-', + pathname: window ? window.location.pathname : '-', + hash: window ? window.location.hash : '-', }; } export function createError(e: FuelWalletError): FuelWalletError | Error { // biome-ignore lint/suspicious/noExplicitAny: let syntheticError: any = e; - if (e.error && 'stack' in e.error) { syntheticError = new Error(e.error.message); syntheticError.stack = e.error.stack; - } else if (e.reactError) { + } else if (e.reactError && 'componentStack' in e.reactError) { syntheticError = new Error('React Error'); syntheticError.stack = e.reactError.componentStack; }