Fix 12145 - Ledger errors being set as `Error: [object, object]` (#12176)

* Fixes #12145

When transactions fail, preserve error message when presented with an error object. Fallback to stringified error for other cases.

* Perserve error stack when err.stack is present, else set stack to message.

* Use optional chaining
feature/default_network_editable
Thomas Huang 3 years ago committed by GitHub
parent 1ca02cb633
commit 02a4da9ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/scripts/controllers/transactions/tx-state-manager.js
  2. 2
      app/scripts/lib/cleanErrorStack.js

@ -521,7 +521,7 @@ export default class TransactionStateManager extends EventEmitter {
const txMeta = this.getTransaction(txId);
txMeta.err = {
message: error.toString(),
message: error.message?.toString() || error.toString(),
rpc: error.value,
stack: error.stack,
};

@ -14,7 +14,7 @@ export default function cleanErrorStack(err) {
err.stack = err.message;
} else if (msg === '') {
err.stack = err.name;
} else {
} else if (!err.stack) {
err.stack = `${err.name}: ${err.message}`;
}

Loading…
Cancel
Save