@jaypie/errors
Error class definitions for Jaypie applications.
Overview
Section titled “Overview”@jaypie/errors provides a comprehensive set of error classes for common HTTP status codes and application errors:
- HTTP error classes (400, 401, 403, 404, 500, etc.)
- Base
JaypieErrorclass - Error factory functions
- JSON:API error formatting
Installation
Section titled “Installation”npm install @jaypie/errorsKey Features
Section titled “Key Features”Error Classes
Section titled “Error Classes”Pre-defined error classes for common HTTP status codes:
import { BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, InternalError,} from "@jaypie/errors";
throw new BadRequestError("Invalid input");throw new NotFoundError("User not found");throw new InternalError("Database connection failed");JaypieError Base Class
Section titled “JaypieError Base Class”All errors extend the base JaypieError class, which includes:
statusCode- HTTP status codemessage- Error message- JSON:API formatting
- Logging integration
Error Factory
Section titled “Error Factory”Create custom errors with specific status codes:
import { errorFactory } from "@jaypie/errors";
const CustomError = errorFactory(418, "I'm a teapot");throw new CustomError("Cannot brew coffee");API Documentation
Section titled “API Documentation”API documentation will be generated from TypeScript definitions.
Related Packages
Section titled “Related Packages”- @jaypie/core - Core utilities
- @jaypie/express - Express.js integration
- @jaypie/lambda - AWS Lambda integration