diff --git a/docs/api/context.md b/docs/api/context.md index 708435e..4cacee3 100644 --- a/docs/api/context.md +++ b/docs/api/context.md @@ -102,10 +102,11 @@ throw err; error messages since you do not want to leak failure details. - You may optionall pass a `properties` object which is merged into the error as-is, useful for decorating machine-friendly errors which are reported to the requester upstream. + You may optionally pass a `properties` object which is merged into the error as-is, useful for decorating machine-friendly errors which are reported to the requester upstream. ```js this.throw(401, 'access_denied', { user: user }); +this.throw('access_denied', { user: user }); ``` ### ctx.respond diff --git a/test/context/throw.js b/test/context/throw.js index 3f5d4c0..8b016a0 100644 --- a/test/context/throw.js +++ b/test/context/throw.js @@ -191,3 +191,19 @@ describe('ctx.throw(status, props)', function(){ } }) }) + +describe('ctx.throw(err, props)', function(){ + it('should mixin props', function(done){ + var ctx = context(); + + try { + ctx.throw(new Error('test'), { prop: true }); + } catch (err) { + assert('test' == err.message); + assert(500 == err.status); + assert(false === err.expose); + assert(true === err.prop); + done(); + } + }) +})