UNPKG

@ingeze/api-error

Version:

A TypeScript library for handling HTTP errors in Express, NestJS, and Fastify APIs.

69 lines (68 loc) 1.88 kB
import { ErrorHandler } from "./error-handler.js"; class NotFoundError extends ErrorHandler { constructor(messageOrDetails, type = "NOT_FOUND", details) { if (typeof messageOrDetails === "string") { super(messageOrDetails, 404, type, details); } else { super("Resource not found", 404, type, messageOrDetails); } } } class UserNotFoundError extends NotFoundError { constructor(details) { super("User not found", "NOT_FOUND_USER", details); } } class EmailNotFoundError extends NotFoundError { constructor(details) { super("Email not found", "NOT_FOUND_EMAIL", details); } } class ProductNotFoundError extends NotFoundError { constructor(details) { super("Product not found", "NOT_FOUND_PRODUCT", details); } } class PostNotFoundError extends NotFoundError { constructor(details) { super("Post not found", "NOT_FOUND_POST", details); } } class CommentNotFoundError extends NotFoundError { constructor(details) { super("Comment not found", "NOT_FOUND_COMMENT", details); } } class CategoryNotFoundError extends NotFoundError { constructor(details) { super("Category not found", "NOT_FOUND_CATEGORY", details); } } class FileNotFoundError extends NotFoundError { constructor(details) { super("File not found", "NOT_FOUND_FILE", details); } } class ImageNotFoundError extends NotFoundError { constructor(details) { super("Image not found", "NOT_FOUND_IMAGE", details); } } class AddressNotFoundError extends NotFoundError { constructor(details) { super("Address not found", "NOT_FOUND_ADDRESS", details); } } export { AddressNotFoundError, CategoryNotFoundError, CommentNotFoundError, EmailNotFoundError, FileNotFoundError, ImageNotFoundError, NotFoundError, PostNotFoundError, ProductNotFoundError, UserNotFoundError }; //# sourceMappingURL=not-found-error.js.map