support errors and update docs

This commit is contained in:
Ian Storm Taylor 2014-08-12 13:22:33 -07:00
parent 5931714bd8
commit dc0c35471c
2 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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();
}
})
})