import type { Exact } from '@skyleague/axioms/types'; import type { ErrorObject } from 'ajv'; import { HttpError } from '../../events/apigateway/event/functions/http-error.js'; import type { HTTPHeaders, HTTPMethod } from '../../events/apigateway/types.js'; import type { Logger } from '../../observability/logger/logger.js'; import type { StandardSchemaV1 } from './standard-schema.js'; export declare const httpStatusCodes: Record; export type ErrorLike = Error | string; /** * @group Errors */ export interface EventOptions { level?: 'error' | 'info' | 'warning' | undefined; errorHandling?: 'graceful' | 'throw' | undefined; expose?: boolean | undefined; headers?: HTTPHeaders | undefined; statusCode?: number | undefined; attributes?: unknown | undefined; cause?: unknown | undefined; ctor?: ((...args: any[]) => any) | Function | undefined; name?: string | undefined; } /** * @group Errors */ export declare class EventError extends Error implements HttpError { isEventError: boolean; forceLevel: 'error' | 'info' | 'warning' | undefined; thrown: boolean; original: unknown; errorHandling: 'graceful' | 'throw'; error: string; expose: boolean; headers: HTTPHeaders | undefined; message: string; statusCode: number; attributes: unknown | undefined; static schema: { readonly type: "object"; readonly title: "HttpError"; readonly properties: { readonly statusCode: { readonly type: "integer"; readonly description: "The status code of the response."; }; readonly message: { readonly type: "string"; readonly description: "A detailed message of the error."; }; }; readonly description: "The default error error response for both 400 & 500 type errors"; readonly required: readonly ["statusCode", "message"]; readonly additionalProperties: true; }; static is: (o: unknown) => o is HttpError; constructor(message?: ErrorLike, { expose, headers, statusCode, attributes, cause, level, errorHandling, ctor, name, }?: EventOptions); get level(): 'error' | 'info' | 'warning'; get isInformational(): boolean; get isSuccess(): boolean; get isRedirection(): boolean; get isClientError(): boolean; get isServerError(): boolean; static log(logger: Logger, error: EventError | unknown, mode?: 'error' | 'level'): EventError; static _is(e: EventError | O): e is EventError; static from(error: EventError | unknown): EventError; static validation(options?: EventOptions & ({ errors?: ErrorObject[] | null | undefined; location?: string; } | { issues: { message: string; path?: (string | number | symbol)[]; }[]; message: string; } | { left?: ErrorObject[] | null | undefined; location?: string; } | { success: false; error: { issues: { message: string; path?: (string | number | symbol)[]; }[]; message: string; }; data?: never; } | StandardSchemaV1.FailureResult)): ValidationError; static badRequest>(message?: ErrorLike, options?: T): EventError; static unauthorized>(message: ErrorLike, options?: T): EventError; static paymentRequired>(message?: ErrorLike, options?: T): EventError; static forbidden>(message?: ErrorLike, options?: T): EventError; static notFound>(message?: ErrorLike, options?: T): EventError; static methodNotAllowed(options: EventOptions & { allow: HTTPMethod[]; message?: ErrorLike; }): EventError; static notAcceptable>(message?: ErrorLike, options?: T): EventError; static proxyAuthRequired>(message?: ErrorLike, options?: T): EventError; static requestTimeout>(message?: ErrorLike, options?: T): EventError; static conflict>(message?: ErrorLike, options?: T): EventError; static gone>(message?: ErrorLike, options?: T): EventError; static lengthRequired>(message?: ErrorLike, options?: T): EventError; static preconditionFailed>(message?: ErrorLike, options?: T): EventError; static payloadTooLarge>(message?: ErrorLike, options?: T): EventError; static uriTooLong>(message?: ErrorLike, options?: T): EventError; static unsupportedMediaType>(message?: ErrorLike, options?: T): EventError; static rangeNotSatisfiable>(message?: ErrorLike, options?: T): EventError; static expectationFailed>(message?: ErrorLike, options?: T): EventError; static teapot>(message?: ErrorLike, options?: T): EventError; static unprocessableEntity>(message?: ErrorLike, options?: T): EventError; static locked>(message?: ErrorLike, options?: T): EventError; static failedDependency>(message?: ErrorLike, options?: T): EventError; static tooEarly>(message?: ErrorLike, options?: T): EventError; static preconditionRequired>(message?: ErrorLike, options?: T): EventError; static tooManyRequests>(message?: ErrorLike, options?: T): EventError; static noResponse>(message?: ErrorLike, options?: T): EventError; static unavailableForLegalReasons>(message?: ErrorLike, options?: T): EventError; static retryable>(message?: ErrorLike, options?: T): EventError; static internal>(message?: ErrorLike, options?: T): EventError; static internalServerError>(message?: ErrorLike, options?: T): EventError; static notImplemented>(message?: ErrorLike, options?: T): EventError; static unexpectedEventType>(message?: ErrorLike, options?: T): EventError; static badGateway>(message?: ErrorLike, options?: T): EventError; static serviceUnavailable>(message?: ErrorLike, options?: T): EventError; static gatewayTimeout>(message?: ErrorLike, options?: T): EventError; static loopDetected>(message?: ErrorLike, options?: T): EventError; } export interface Issue { readonly message: string; readonly path?: ReadonlyArray | undefined; } export interface PathSegment { readonly key: PropertyKey; } export declare class ValidationError extends EventError { readonly issues: readonly Issue[]; constructor(message?: ErrorLike, options?: EventOptions & { issues?: readonly Issue[]; }); }