import type { CommandErrorResponse } from '../types/commandType/CommandErrorResponse.js'; import type { ErrorResponsePayload } from '../types/ErrorResponsePayload.js'; import { StatusCode } from '../types/StatusCode.enum.js'; import type { TraceId } from '../types/TraceId.js'; /** * A handled error is an error which is handled or thrown by business logic. * It is wanted to expose it the outside world. * Scenarios are input validation failures or "404 Not Found" errors which should be returned to the caller. */ export declare class HandledError extends Error { errorCode: StatusCode; data?: unknown; traceId?: TraceId | undefined; constructor(errorCode: StatusCode, message?: string, data?: unknown, traceId?: TraceId | undefined); /** * Create a error object from EBMessage error message * @param message CommandErrorResponse * @returns HandledError */ static fromMessage(message: Readonly): HandledError; /** * Creates a HandledError from an input. * If the input error is a HandledError it will be returned without modifications. * * @param err the input * @param errorCode the error code * @param data optional data * @param traceId optional trace id * @returns HandledError */ static fromError(err: unknown, errorCode?: StatusCode, data?: unknown, traceId?: TraceId): HandledError; /** * Returns error response object * @returns ErrorResponsePayload */ getErrorResponse(traceId?: TraceId): Readonly; /** * Returns stringified error response object * @returns ErrorResponse as string */ toString(): string; toJSON(): { status: StatusCode; message: string; traceId?: TraceId; data?: unknown; stack: string | undefined; name: string; }; } //# sourceMappingURL=HandledError.impl.d.ts.map