@ingeze/api-error
Version:
A TypeScript library for handling HTTP errors in Express, NestJS, and Fastify APIs.
18 lines (17 loc) • 435 B
JavaScript
import { ErrorHandler } from "../errors/index.js";
function fastifyErrorMiddleware(err, req, reply) {
if (err instanceof ErrorHandler) {
reply.code(err.statusCode).send(err.toJSON());
return;
}
reply.code(500).send({
success: false,
type: "INTERNAL_SERVER_ERROR",
statusCode: 500,
message: err.message || "Unexpected error"
});
}
export {
fastifyErrorMiddleware
};
//# sourceMappingURL=fastify.js.map