Skip to content

Commit

Permalink
Move crazy substring to be inside the trycatch
Browse files Browse the repository at this point in the history
  • Loading branch information
BelfordZ committed Jul 13, 2022
1 parent e53bd44 commit 59d57c3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1461,12 +1461,12 @@ export default class TransactionController extends EventEmitter {
// error ends up wrapped in a string & inside .value because of
// https://github.com/ethjs/ethjs-rpc/blob/master/src/index.js#L52
// https://github.com/ethjs/ethjs-query/blob/master/src/index.js#L78
let errorJson = error.message.substring(
error.message.indexOf("{"),
error.message.indexOf(',"code"')
) + '}}}';
let unwrapped;
try {
let errorJson = error.message.substring(
error.message.indexOf("{"),
error.message.indexOf(',"code"')
) + '}}}';
errorJson = JSON.parse(errorJson);
unwrapped = new Error(errorJson.value.data.message);
unwrapped.code = errorJson.value.code;
Expand Down

0 comments on commit 59d57c3

Please sign in to comment.