Skip to content

Commit

Permalink
Replace errorStack string by causedBy error type
Browse files Browse the repository at this point in the history
  • Loading branch information
xdzurman committed Jul 8, 2020
1 parent 2bdb9c0 commit f92f97c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/frontend/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF
try {
txAux = wallet.prepareTxAux(state.sendTransactionSummary.plan)
} catch (e) {
throw NamedError('TransactionCorrupted', {errorStack: e.stack})
throw NamedError('TransactionCorrupted', {causedBy: e})
}

setState({
Expand Down
6 changes: 4 additions & 2 deletions app/frontend/helpers/NamedError.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
type OptionalParams = {
message?: string
errorStack?: string
causedBy?: Error
}

function NamedError(name: string, optionalParams: OptionalParams = {}) {
const e = new Error(optionalParams.message || name)
e.name = name
e.message = optionalParams.message || ''
e.stack = optionalParams.errorStack || e.stack
e.stack = optionalParams.causedBy
? `\nError caused by:\n${optionalParams.causedBy.stack}`
: e.stack
return e
}

Expand Down

0 comments on commit f92f97c

Please sign in to comment.