remove stack trace concatenation (non-standard), modify error message only
This commit is contained in:
parent
617c1c9ee9
commit
7a9c3b0ddd
|
@ -550,18 +550,11 @@ function execute(cmd, message) {
|
||||||
function onError(message, error) {
|
function onError(message, error) {
|
||||||
// log the stack trace
|
// log the stack trace
|
||||||
if (config.debug) { console.error(error.stack); }
|
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
|
// update error message
|
||||||
if (error.stack.indexOf(error.message) === -1) {
|
error.message = message + ': ' + error.message;
|
||||||
error.stack = 'Error: ' + error.message + '\n' + error.stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
//newError.innerError = error;
|
throw error;
|
||||||
newError.stack += '\n' + error.stack;
|
|
||||||
|
|
||||||
throw newError;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1202,7 +1202,8 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Errors', function() {
|
describe('Errors', function() {
|
||||||
it('Error stack should contain the stack of the original error', function(done) {
|
|
||||||
|
it('Error message should contain the original error message', function(done) {
|
||||||
return openpgp.encrypt({
|
return openpgp.encrypt({
|
||||||
data: new Uint8Array([0x01, 0x01, 0x01]),
|
data: new Uint8Array([0x01, 0x01, 0x01]),
|
||||||
passwords: null
|
passwords: null
|
||||||
|
@ -1211,23 +1212,10 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
done(new Error('Error expected.'));
|
done(new Error('Error expected.'));
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
expect(error.stack).to.match(/\nError: No keys or passwords/);
|
expect(error.message).to.match(/No keys or passwords/);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
// it('Errors should contain innerError', function(done) {
|
|
||||||
// openpgp.encrypt({
|
|
||||||
// data: new Uint8Array([0x01, 0x01, 0x01]),
|
|
||||||
// passwords: null
|
|
||||||
// })
|
|
||||||
// .then(function() {
|
|
||||||
// done(new Error('Error expected.'));
|
|
||||||
// })
|
|
||||||
// .catch(function(error) {
|
|
||||||
// expect(error.innerError).to.exist;
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user