Skip to content

Commit 480a9f2

Browse files
author
lukaw3d
committed
stake: refactor toErrorString
1 parent e8632e9 commit 480a9f2

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

ui/src/stake/utils/errors.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
export const toErrorString = (error: Error = new Error('Unknown error')) => {
2-
let errorString = ''
3-
4-
if (Object.prototype.hasOwnProperty.call(error, 'message')) {
5-
errorString = (error as Error).message
6-
} else if (typeof error === 'object') {
7-
errorString = JSON.stringify(error)
8-
} else {
9-
errorString = error
10-
}
11-
12-
return errorString
2+
if ('message' in error) return error?.message
3+
if (typeof error === 'object') return JSON.stringify(error)
4+
return error
135
}

0 commit comments

Comments
 (0)