honestjs
Version:
HonestJS - a modern web framework built on top of Hono
26 lines (25 loc) • 1.1 kB
TypeScript
import type { Context } from 'hono';
import type { ContentfulStatusCode } from 'hono/utils/http-status';
import type { ErrorResponse } from '../interfaces';
/**
* Creates a standardized error response object
* @param exception - The error or exception object to process
* @param context - The Hono context object containing request information
* @param options - Optional configuration for the error response
* @param options.status - HTTP status code to override the default
* @param options.title - Custom error message to override the default
* @param options.detail - Additional error details
* @param options.code - Custom error code
* @param options.additionalDetails - Extra information to include in the response
* @returns Object containing the formatted error response and HTTP status code
*/
export declare function createErrorResponse(exception: Error, context: Context, options?: {
status?: number;
title?: string;
detail?: string;
code?: string;
additionalDetails?: Record<string, any>;
}): {
response: ErrorResponse;
status: ContentfulStatusCode;
};