Skip parsing cause if it is not an Error object

This commit is contained in:
angrycat9000
2023-07-19 10:00:50 -04:00
parent e56bd3918b
commit 2ddb344bac
2 changed files with 21 additions and 1 deletions

View File

@@ -291,6 +291,26 @@ describe('ExceptionFormatter', function() {
.withContext('first root cause stack frame')
.toContain('ExceptionFormatterSpec.js');
});
it('does not throw if cause is a non Error', function() {
const formatter = new jasmineUnderTest.ExceptionFormatter();
expect(function() {
formatter.stack(
new Error('error', {
cause: function() {}
})
);
}).not.toThrowError();
expect(function() {
formatter.stack(
new Error('error', {
cause: 'another error'
})
);
}).not.toThrowError();
});
});
});
});