From 7f3d0765d761bd05f330ef2e210c811b425b12b9 Mon Sep 17 00:00:00 2001 From: Remek Ambroziak Date: Fri, 21 Apr 2017 15:49:06 +0200 Subject: [PATCH] docs: fix documentation to match new http-errors API (#957) (#967) --- docs/api/context.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/api/context.md b/docs/api/context.md index dc870cd..b4b65c5 100644 --- a/docs/api/context.md +++ b/docs/api/context.md @@ -85,20 +85,19 @@ koa uses the [cookies](https://github.com/jed/cookies) module where options are koa uses the [cookies](https://github.com/jed/cookies) module where options are simply passed. -### ctx.throw([msg], [status], [properties]) +### ctx.throw([status], [msg], [properties]) Helper method to throw an error with a `.status` property defaulting to `500` that will allow Koa to respond appropriately. The following combinations are allowed: ```js -ctx.throw(403); -ctx.throw('name required', 400); +ctx.throw(400); ctx.throw(400, 'name required'); -ctx.throw('something exploded'); +ctx.throw(400, 'name required', { user: user }); ``` - For example `ctx.throw('name required', 400)` is equivalent to: + For example `ctx.throw(400, 'name required')` is equivalent to: ```js const err = new Error('name required'); @@ -117,7 +116,6 @@ throw err; ```js ctx.throw(401, 'access_denied', { user: user }); -ctx.throw('access_denied', { user: user }); ``` koa uses [http-errors](https://github.com/jshttp/http-errors) to create errors.