diff --git a/src/openpgp.js b/src/openpgp.js index f6dff886..9c30f17d 100644 --- a/src/openpgp.js +++ b/src/openpgp.js @@ -552,8 +552,15 @@ function onError(message, error) { if (config.debug) { console.error(error.stack); } // rethrow new high level error for api users const newError = new Error(message + ': ' + error.message); + + // Standardize stack trace for tests + if (error.stack.indexOf(error.message) === -1) { + error.stack = 'Error: ' + error.message + '\n' + error.stack; + } + //newError.innerError = error; newError.stack += '\n' + error.stack; + throw newError; }