Skip to main content

Errors

Module Overview

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)
}
  • Keywork#HTTP#Response.ErrorResponse ErrorResponse

Usage

import * as Errors from 'keywork/errors'

Enumerations

Error Classes

Error Interfaces

Variables