@forgeframework/errors
v0.3.0
Published
Standardized error hierarchy for the Forge Framework.
Maintainers
Readme
@forgeframework/errors
Standardized error hierarchy for the Forge Framework.
Part of the Forge Framework — a TypeScript framework for backend microservices and web applications.
Installation
npm install @forgeframework/errorsUsage
import {
ForgeError,
ForgeNotFoundError,
ForgeValidationError,
ForgeUnauthorizedError,
} from '@forgeframework/errors';
function findUser(id: string): User {
const user = db.get(id);
if (!user) throw new ForgeNotFoundError('User', id);
return user;
}
function validateInput(data: unknown): void {
const violations = validate(data);
if (violations.length > 0) {
throw new ForgeValidationError('Invalid input', violations);
}
}Documentation
Full API reference and guides: https://carbonforge.io/framework/docs/core/errors
(Documentation site launching soon.)
License
MIT © Carbon Forge
