Skip to content

Commit

Permalink
ALL-2054 - Add error log link (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hathoriel committed Aug 8, 2023
1 parent ee01131 commit 853e171
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [3.0.5] - 2023.08.07
### Changed
- In all error responses expects for RPC, error object returns also `dashboardLog` which points to the dashboard error log

## [3.0.4] - 2023.08.07
### Changed
- Added EVM debug_traceBlock and eth_getBlockReceipts methods
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tatumio/tatum",
"version": "3.0.4",
"version": "3.0.5",
"description": "Tatum JS SDK",
"author": "Tatum",
"repository": "https://github.com/tatumio/tatum-js",
Expand Down
8 changes: 7 additions & 1 deletion src/util/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ResponseDto<T> {
type ErrorWithMessage = {
message: string[] | object[]
code?: string
dashboardLog?: string
}

export const ErrorUtils = {
Expand Down Expand Up @@ -66,24 +67,29 @@ export const ErrorUtils = {
return {
message: (error.data as string[]).map((message) => ErrorUtils.formatErrorMsg(message)),
code: error.errorCode,
dashboardLog: error.dashboardLog,
}
}

return {
message: [error.message ?? maybeError],
code: error.errorCode,
dashboardLog: error.dashboardLog,
}
// eslint-disable-next-line no-empty
} catch (_) {}
}

if (ErrorUtils.isErrorWithMessage(maybeError)) {
return { message: [maybeError.message] }
return { message: [maybeError.message], dashboardLog: maybeError.dashboardLog }
}

try {
return {
message: [JSON.stringify(maybeError, null, 2)],
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
dashboardLog: maybeError.dashboardLog,
}
} catch {
// fallback in case there's an error stringifying the maybeError
Expand Down

0 comments on commit 853e171

Please sign in to comment.