-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generic message for errors during sign operation
- Loading branch information
1 parent
76011d1
commit d03573c
Showing
5 changed files
with
52 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,37 @@ | ||
import { handleTezError } from "./estimate"; | ||
|
||
export type ErrorContext = { | ||
timestamp: string; | ||
description: string; | ||
stacktrace: string; | ||
technicalDetails: string; | ||
}; | ||
|
||
export const getErrorContext = (error: any): ErrorContext => { | ||
let description = "Something went wrong"; | ||
if (typeof error === "object" && "message" in error) { | ||
description = error.message; | ||
} else if (typeof error === "string") { | ||
description = error; | ||
} | ||
console.log({ error }); | ||
let description = | ||
"Something went wrong. Please try again or contact support if the issue persists."; | ||
let technicalDetails; | ||
|
||
let stacktrace = ""; | ||
if (typeof error === "object" && "stack" in error) { | ||
stacktrace = error.stack; | ||
} | ||
|
||
if (error instanceof Error) { | ||
description = handleTezError(error) ?? description; | ||
} | ||
|
||
if (typeof error === "object" && "message" in error) { | ||
technicalDetails = error.message; | ||
} else if (typeof error === "string") { | ||
technicalDetails = error; | ||
} | ||
|
||
return { | ||
timestamp: new Date().toISOString(), | ||
description, | ||
stacktrace, | ||
technicalDetails, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters