import * as keywork from "https://deno.land/x/keywork@v6.2.1/errors/mod.ts";
Keywork includes error utilities that pair nicely with HTTP request handlers.
import { KeyworkResourceError, StatusCodes } from 'keywork/errors'
if (isLoggedIn(someUser)) {
throw new KeyworkResourceError('You must be logged in to do that', StatusCodes.UNAUTHORIZED)
}
if (someUser.role !== 'admin') {
throw new KeyworkResourceError('Only an admin can access that', StatusCodes.FORBIDDEN)
}
Related Entries
- Keywork#HTTP#Response.ErrorResponse |
ErrorResponse
Classes
An error class that feels fits nicely into an incoming HTTP request handler. |
Variables
Used in place of the reference-sensitive | |
A record of all the status codes text. |
Interfaces
A JSON representation of a |