import { HTTPError } from "https://deno.land/x/drash@v3.0.0-beta.2/src/core/errors/HTTPError.ts";
Base class for all HTTP errors in Drash. Use this class to throw uniform HTTP errors.
Examples
Example 1
Example 1
// Usage in resource's GET method
class MyResource extends Resource {
public GET(request: Request) {
if (!request.header("authorization")) {
throw new HTTPError(401, "Get out!");
}
return new Response("Authed");
}
}
Constructors
new
HTTPError(status: ResponseStatus, message?: string)Properties
The name of this error to be used with conditionals that do not work with
instanceof
.
readonly
status_code: ResponseStatusCodeThe HTTP status code associated with this error.