Description: The JSDoc for HttpError in Koa states:
A re-export of HttpError from the http-error package. This is the error type that is thrown by ctx.assert() and ctx.throw().
However, ctx.assert() actually throws specific error class, not the HttpError class. This breaks instanceof HttpError checks in error handling.
Code to reproduce
import { HttpError } from 'koa'
const router = new Router()
router.get('/test', async (ctx) => {
try {
const data = null
ctx.assert(data, 401, 'Unauthorized')
} catch (e) {
console.log(e instanceof HttpError) // ❌ false - should be true
}
})
Description: The JSDoc for HttpError in Koa states:
However, ctx.assert() actually throws specific error class, not the HttpError class. This breaks instanceof HttpError checks in error handling.
Code to reproduce