import { ZodFormattedError } from 'zod' export type ICustomError = Error & { message: string status: string statusCode: number details?: ZodFormattedError } export type IApiError = ICustomError & { isApiError: boolean } export class CustomError extends Error implements ICustomError { statusCode: number status: string details?: ZodFormattedError constructor( statusCode: number, message: string, details?: ZodFormattedError, ) { super(message) this.statusCode = statusCode this.status = 'error' this.details = details Error.captureStackTrace(this, this.constructor) } } export class ApiError extends CustomError implements IApiError { isApiError: boolean = true }