UNPKG

@visulima/error

Version:

Error with more than just a message, stacktrace parsing.

78 lines (69 loc) 2.58 kB
import { b as CodeFrameOptions, c as ColorizeMethod } from '../packem_shared/types-CrVmNoPV.cjs'; declare const captureRawStackTrace: () => string | undefined; interface ErrorProperties { cause?: Error | unknown; hint?: ErrorHint; location?: ErrorLocation; message?: string; name: string; stack?: string; title?: string; } interface ErrorLocation { column?: number; file?: string; line?: number; } type ErrorHint = string[] | string; declare const isVisulimaError: (error: unknown) => error is VisulimaError; declare class VisulimaError extends Error { loc: ErrorLocation | undefined; title: string | undefined; hint: ErrorHint | undefined; type: string; constructor({ cause, hint, location, message, name, stack, title }: ErrorProperties); setLocation(location: ErrorLocation): void; setName(name: string): void; setMessage(message: string): void; setHint(hint: ErrorHint): void; } declare const getErrorCauses: <E = Error | VisulimaError | unknown>(error: E) => E[]; type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & { color: CodeFrameOptions["color"] & { fileLine: ColorizeMethod; hint: ColorizeMethod; method: ColorizeMethod; title: ColorizeMethod; }; cwd: string; displayShortPath: boolean; filterStacktrace: ((line: string) => boolean) | undefined; framesMaxLimit: number; hideErrorCauseCodeView: boolean; hideErrorCodeView: boolean; hideErrorErrorsCodeView: boolean; hideErrorTitle: boolean; hideMessage: boolean; indentation: number | "\t"; prefix: string; }; declare const renderError: (error: AggregateError | Error | VisulimaError, options?: Partial<Options$1>) => string; type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & { aggregateErrors?: SerializedError<ErrorType>[]; cause?: unknown; code?: string; message: string; name: string; raw?: ErrorType; stack?: string; }; interface JsonError extends Error { toJSON: () => SerializedError; } type Options = { exclude?: string[]; maxDepth?: number; useToJSON?: boolean; }; declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError; export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type Options$1 as RenderErrorOptions, type SerializedError, VisulimaError, captureRawStackTrace, getErrorCauses, isVisulimaError, renderError, serialize as serializeError };