Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const { LEVEL, MESSAGE } = require('triple-beam');
*
* Optionally, the Error's `stack` and/or `cause` properties can also be appended to the `info` object.
*/
module.exports = format((einfo, { stack, cause }) => {
module.exports = format((einfo, opts = {}) => {
const { stack, cause } = opts;
if (einfo instanceof Error) {
const info = Object.assign({}, einfo, {
level: einfo.level,
Expand Down
11 changes: 11 additions & 0 deletions test/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,14 @@ describe('errors()(Error)', () => {
{ immutable: false }
));
});

describe('errors().transform called without options', () => {
it('does not throw when transform is called with a single argument', () => {
const errorsFormat = errors({ stack: true });
const transformErr = new Error('Oh no!');
const info = errorsFormat.transform(transformErr);
assume(info).is.an('object');
assume(info.message).equals(transformErr.message);
assume(info[MESSAGE]).equals(transformErr.message);
});
});