diff --git a/errors.js b/errors.js index b1d163b..aa297f3 100644 --- a/errors.js +++ b/errors.js @@ -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, diff --git a/test/errors.test.js b/test/errors.test.js index 32ae79c..05cacd7 100644 --- a/test/errors.test.js +++ b/test/errors.test.js @@ -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); + }); +});