diff options
author | Anton <anton@chainsecurity.com> | 2018-05-29 04:57:08 +0800 |
---|---|---|
committer | Anton <anton@chainsecurity.com> | 2018-05-29 04:57:08 +0800 |
commit | 71a6e97327a4c759942784ee81505e3bc5ed545e (patch) | |
tree | a7ac713e5b2f0cd700d3e55203ec56ce089a2414 /app/scripts/lib | |
parent | 1d23a5c81b03b8b52225e942603c84b237d4e63c (diff) | |
download | tangerine-wallet-browser-71a6e97327a4c759942784ee81505e3bc5ed545e.tar.gz tangerine-wallet-browser-71a6e97327a4c759942784ee81505e3bc5ed545e.tar.zst tangerine-wallet-browser-71a6e97327a4c759942784ee81505e3bc5ed545e.zip |
cleanErrorStack moved to separate library module
more errors traces cleaned up
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/cleanErrorStack.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/scripts/lib/cleanErrorStack.js b/app/scripts/lib/cleanErrorStack.js new file mode 100644 index 000000000..fe1bfb0ce --- /dev/null +++ b/app/scripts/lib/cleanErrorStack.js @@ -0,0 +1,24 @@ +/** + * Returns error without stack trace for better UI display + * @param {Error} err - error + * @returns {Error} Error with clean stack trace. + */ +function cleanErrorStack(err){ + var name = err.name + name = (name === undefined) ? 'Error' : String(name) + + var msg = err.message + msg = (msg === undefined) ? '' : String(msg) + + if (name === '') { + err.stack = err.message + } else if (msg === '') { + err.stack = err.name + } else { + err.stack = err.name + ': ' + err.message + } + + return err +} + +module.exports = cleanErrorStack |