Skip to content

Commit

Permalink
fix: handling error format to improve further sentry identification (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
rodrigobranas authored Jun 27, 2024
1 parent d49b9ef commit 3966aa9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-apes-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels-wallet": minor
---

Improved error handling and including location informations to support better understanding about the causes of erros
6 changes: 4 additions & 2 deletions packages/app/src/systems/Error/utils/parseFuelError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: <explanation>
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;
}
Expand Down

0 comments on commit 3966aa9

Please sign in to comment.