Include inner exceptions in stack traces
This commit is contained in:
@@ -44,18 +44,38 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const stackTrace = new j$.StackTrace(error);
|
||||
const lines = filterJasmine(stackTrace);
|
||||
let result = '';
|
||||
const lines = this.stack_(error, {
|
||||
messageHandling: omitMessage ? 'omit' : undefined
|
||||
});
|
||||
return lines.join('\n');
|
||||
};
|
||||
|
||||
if (stackTrace.message && !omitMessage) {
|
||||
// messageHandling can be falsy (unspecified), 'omit', or 'require'
|
||||
this.stack_ = function(error, { messageHandling }) {
|
||||
let lines = formatProperties(error).split('\n');
|
||||
|
||||
if (lines[lines.length - 1] === '') {
|
||||
lines.pop();
|
||||
}
|
||||
|
||||
const stackTrace = new j$.StackTrace(error);
|
||||
lines = lines.concat(filterJasmine(stackTrace));
|
||||
|
||||
if (messageHandling === 'require') {
|
||||
lines.unshift(stackTrace.message || 'Error: ' + error.message);
|
||||
} else if (messageHandling !== 'omit' && stackTrace.message) {
|
||||
lines.unshift(stackTrace.message);
|
||||
}
|
||||
|
||||
result += formatProperties(error);
|
||||
result += lines.join('\n');
|
||||
if (error.cause) {
|
||||
const substack = this.stack_(error.cause, {
|
||||
messageHandling: 'require'
|
||||
});
|
||||
substack[0] = 'Caused by: ' + substack[0];
|
||||
lines = lines.concat(substack);
|
||||
}
|
||||
|
||||
return result;
|
||||
return lines;
|
||||
};
|
||||
|
||||
function filterJasmine(stackTrace) {
|
||||
|
||||
Reference in New Issue
Block a user