import { HTTPException } from "https://deno.land/x/hono@v4.2.7/http-exception.ts";
HTTPException
must be used when a fatal error such as authentication failure occurs.
Examples
Example 1
Example 1
import { HTTPException } from 'hono/http-exception'
// ...
app.post('/auth', async (c, next) => {
// authentication
if (authorized === false) {
throw new HTTPException(401, { message: 'Custom error message' })
}
await next()
})
Constructors
new
HTTPException(status?: StatusCode, options?: HTTPExceptionOptions)Properties
readonly
optional
res: Responsereadonly
status: StatusCode