Skip to content

Commit 4c34546

Browse files
authored
1 parent ce6b3b6 commit 4c34546

File tree

4 files changed

+34
-51
lines changed

4 files changed

+34
-51
lines changed

__tests__/application/use.test.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ describe('app.use(fn)', () => {
7373
it('should catch thrown errors in non-async functions', () => {
7474
const app = new Koa()
7575

76-
app.use(ctx => ctx.throw('Not Found', 404))
76+
app.use(ctx => ctx.throw(404, 'Not Found'))
7777

78-
return request(app.callback())
79-
.get('/')
80-
.expect(404)
78+
return request(app.callback()).get('/').expect(404)
8179
})
8280

8381
it('should throw error for non-function', () => {

__tests__/context/throw.test.js

-29
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@ describe('ctx.throw(err)', () => {
3232
})
3333
})
3434

35-
describe('ctx.throw(err, status)', () => {
36-
it('should throw the error and set .status', () => {
37-
const ctx = context()
38-
const error = new Error('test')
39-
40-
try {
41-
ctx.throw(error, 422)
42-
} catch (err) {
43-
assert.strictEqual(err.status, 422)
44-
assert.strictEqual(err.message, 'test')
45-
assert.strictEqual(err.expose, true)
46-
}
47-
})
48-
})
49-
5035
describe('ctx.throw(status, err)', () => {
5136
it('should throw the error and set .status', () => {
5237
const ctx = context()
@@ -62,20 +47,6 @@ describe('ctx.throw(status, err)', () => {
6247
})
6348
})
6449

65-
describe('ctx.throw(msg, status)', () => {
66-
it('should throw an error', () => {
67-
const ctx = context()
68-
69-
try {
70-
ctx.throw('name required', 400)
71-
} catch (err) {
72-
assert.strictEqual(err.message, 'name required')
73-
assert.strictEqual(err.status, 400)
74-
assert.strictEqual(err.expose, true)
75-
}
76-
})
77-
})
78-
7950
describe('ctx.throw(status, msg)', () => {
8051
it('should throw an error', () => {
8152
const ctx = context()

package-lock.json

+31-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"escape-html": "^1.0.3",
5151
"fresh": "~0.5.2",
5252
"http-assert": "^1.3.0",
53-
"http-errors": "^1.6.3",
53+
"http-errors": "^2.0.0",
5454
"koa-compose": "^4.1.0",
5555
"on-finished": "^2.3.0",
5656
"parseurl": "^1.3.2",

0 commit comments

Comments
 (0)