Get Started
Zeta has built-in error handling.
By default, all errors thrown inside a handler or hook are mapped to a 500 Internal Server Error response. The original error will be the cause.
;
;
-> GET /users
<- 500 Internal Server Error
<-
Regular Error instances are always mapped to a 500 Internal Server Error. To control the status code, you need to throw a HttpError:
;
;
;
-> GET /users
<- 501 Not Implemented
<-
TIP
To disable the stack trace, setNODE_ENV=productionin the environment variables.
Alternatively, you can use a subclass of HttpError so you don't have to manually pass the status into the constructor:
+import { NotImplementedError } from "@aklinker1/zeta";
const app = createApp().get("/users", {}, () => {
- throw new HttpError(HttpStatus.NotImplemented, "TODO");
+ throw new NotImplementedError("TODO");
});