UNPKG

alapa

Version:

A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.

99 lines (98 loc) 3.41 kB
import { BaseApiResponse } from "./base"; export interface ApiErrorResponse extends BaseApiResponse { /** * Optional custom code for additional context about the response. * This can be used to provide more granular information than HTTP status codes. */ code?: number; /** * Detailed description of the error. * This should provide enough context for the user to understand what went wrong. */ details?: string; /** * Optional reference application-specific error code. * This can help in identifying specific errors in the application. */ referenceCode?: string; /** * A human-readable message summarizing the error. * This message can be shown directly to users to convey what happened. */ message?: string; /** * The HTTP status code associated with the error. * This can help the client understand the nature of the failure (e.g., 404, 500). */ statusCode?: number; /** * A timestamp indicating when the error occurred. * Useful for debugging and logging purposes. */ timestamp?: string; /** * An array of validation errors if the error is related to input validation. * This can help users understand what went wrong with their input. */ validationErrors?: Array<{ field: string; message: string; code?: string; }>; /** * Optional links or suggestions for resolving the error. * This can guide users on how to fix the issue or provide further documentation. */ links?: Array<{ href: string; rel: string; }>; /** * Optional context about the request that caused the error. * This may include information about the request parameters, headers, or body. */ requestContext?: { method: string; url: string; headers?: Record<string, string>; body?: Record<string, any>; query?: Record<string, any>; params?: Record<string, any>; }; /** * Optional server-side stack trace or error log. * This is useful for developers and support teams to diagnose issues. */ stackTrace?: string; /** * Optional suggestions or possible causes for the error. * This could guide users on what might have gone wrong. */ suggestions?: Array<string>; /** * User-friendly error category. * This can help in classifying errors for easier handling (e.g., "client error", "server error"). */ category?: "client" | "server" | "network" | "validation" | "authentication" | "authorization" | "timeout" | "resource" | "business logic" | "third-party service" | "data format" | "service unavailable"; /** * Additional context for developers or support teams. * This could include information about the environment (e.g., production, staging) or user session details. */ developerContext?: { environment?: string; userId?: string; sessionId?: string; traceId?: string; correlationId?: string; }; /** * Optional fields for logging purposes. * This can help in centralizing logging and monitoring. */ logging?: { errorId?: string; timestamp?: string; severity?: "info" | "warn" | "error" | "debug"; additionalData?: Record<string, any>; }; }