Lets any layer fail a request with an HTTP status, which the error middleware turns into the response.
c
APIException()
status: APIStatus,
message: string
Thrown by a route, a service or a remote fetch to answer the request with an
error. The error middleware sends it as an APIFailure, message included,
so the message must be fit for the user. Use 401 for a caller who isn't
signed in, 403 for one who is but may not, and 404 rather than 403 when the
caller mustn't learn that the thing exists.
T
APIStatus = 400 | 401 | 403 | 404 | 409 | 429 | 500 | 502
Passed to an APIException; any other status is a type error.
Usage
import * as mod from "api/lib/api-exception.ts";