@stacksjs/error-handling
Version:
Type safe error handling.
71 lines (70 loc) • 2.06 kB
TypeScript
import { languageForFile } from './error-page-highlighter';
import type { ErrorPageConfig, QueryInfo, RequestContext, RoutingContext, UserContext } from './error-page';
declare function parseStackTrace(stack: string | undefined, basePaths?: string[], options?: { includeFrameworkFrames?: boolean }): ParsedFrame[];
declare function groupFrames(frames: ParsedFrame[]): Array<ParsedFrame | ParsedFrame[]>;
export declare function buildErrorPageViewModel(opts: {
error: Error
status: number
config: ErrorPageConfig
framework?: { name: string, version?: string }
request?: RequestContext
routing?: RoutingContext
user?: UserContext
queries?: QueryInfo[]
}): Promise<ErrorPageViewModel>;
export declare interface FrameViewModel {
function: string
file: string
line: number
expanded: boolean
hasCode: boolean
codeHtml: string
isVendor: boolean
}
export declare interface TraceGroupViewModel {
type: 'frame' | 'vendor'
frames: FrameViewModel[]
vendorCount: number
}
export declare interface KeyValueRow {
key: string
value: string
}
export declare interface ErrorPageViewModel {
pageTitle: string
statusTitle: string
markdownJson: string
exceptionClass: string
message: string
fileLine: string
statusCode: number
errorCode: string
frameworkLabel: string
frameworkVersion: string
runtimeLabel: string
runtimeVersion: string
requestMethod: string
requestUrl: string
hasRequest: boolean
hintsHtml: string
traceGroups: TraceGroupViewModel[]
queries: Array<{ connection: string, sql: string, sqlHtml: string, time: string }>
queryCount: number
headers: KeyValueRow[]
bodyContent: string
routing: KeyValueRow[]
routeParamsJson: string
userRows: KeyValueRow[]
environmentRows: KeyValueRow[]
hasUser: boolean
hasEnvironment: boolean
hasQueries: boolean
hasHeaders: boolean
hasBody: boolean
hasRouting: boolean
hasRouteParams: boolean
highlightCss: string
enableCopyMarkdown: boolean
}
// Re-export for tests
export { parseStackTrace, groupFrames, languageForFile };