errorforge-elsolya
v0.1.0
Published
Typed application errors and framework-agnostic error normalization
Maintainers
Readme
errorforge-elsolya
Typed application errors, normalization, and RFC 7807-style Problem Details for Node.js.
Install
npm install errorforge-elsolyaUsage
import { defineErrorCatalog, normalizeError } from "errorforge-elsolya";
const errors = defineErrorCatalog({
USER_NOT_FOUND: { status: 404, message: "User was not found", expose: true },
});
throw errors.USER_NOT_FOUND({ details: { userId: "u_1" } });Express error handler
import { createExpressErrorHandler } from "errorforge-elsolya/express";
app.use(createExpressErrorHandler({ includeStack: process.env.NODE_ENV !== "production" }));Validation engine mappers
import { normalizeError } from "errorforge-elsolya";
import { zodErrorMapper } from "errorforge-elsolya/zod";
normalizeError(error, { mappers: [zodErrorMapper] });Exports
errorforge-elsolya— core catalog + normalizationerrorforge-elsolya/express|fastify|koa|hono|nest|next— framework handlerserrorforge-elsolya/zod|valibot|yup|ajv— validation error mappers
License
MIT
