UNPKG

@dev-abhi/errorify

Version:

A utility package for simplified error handling and management in Node.js applications.

36 lines (35 loc) 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DatabaseValidationError = exports.QueryTimeoutError = exports.DuplicateKeyError = exports.RecordNotFoundError = exports.DatabaseConnectionError = void 0; const errorCodes_1 = require("../../utils/errorCodes"); const CustomError_1 = require("../CustomError"); class DatabaseConnectionError extends CustomError_1.CustomError { constructor(message = "Database Connection Failed", details = {}) { super(message, 500, errorCodes_1.ErrorCodes.DATABASE_CONNECTION_ERROR, details); } } exports.DatabaseConnectionError = DatabaseConnectionError; class RecordNotFoundError extends CustomError_1.CustomError { constructor(message = "Record Not Found", details = {}) { super(message, 404, errorCodes_1.ErrorCodes.RECORD_NOT_FOUND_ERROR, details); } } exports.RecordNotFoundError = RecordNotFoundError; class DuplicateKeyError extends CustomError_1.CustomError { constructor(message = "Duplicate Key Error", details = {}) { super(message, 409, errorCodes_1.ErrorCodes.DUPLICATE_KEY_ERROR, details); } } exports.DuplicateKeyError = DuplicateKeyError; class QueryTimeoutError extends CustomError_1.CustomError { constructor(message = "Query Timeout", details = {}) { super(message, 408, errorCodes_1.ErrorCodes.QUERY_TIMEOUT_ERROR, details); } } exports.QueryTimeoutError = QueryTimeoutError; class DatabaseValidationError extends CustomError_1.CustomError { constructor(message = "Database Validation failed", details = {}) { super(message, 400, errorCodes_1.ErrorCodes.DATABASE_VALIDATION_ERROR, details); } } exports.DatabaseValidationError = DatabaseValidationError;