A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/app/scripts/lib/cleanErrorStack.js

23 lines
544 B

/**
* Returns error without stack trace for better UI display
*
* @param {Error} err - error
* @returns {Error} Error with clean stack trace.
*/
export default function cleanErrorStack(err) {
let { name } = err;
name = name === undefined ? 'Error' : String(name);
let msg = err.message;
msg = msg === undefined ? '' : String(msg);
if (name === '') {
err.stack = err.message;
} else if (msg === '') {
err.stack = err.name;
} else if (!err.stack) {
err.stack = `${err.name}: ${err.message}`;
}
return err;
}