import { ErrorCode, ErrorTags, StandardError, TaggedErrorCode } from './types.js'; export type CauseExtractor = (err: unknown) => ReadonlyArray | undefined; export interface ErrorMatch { readonly value: V; readonly error: E; } export declare class ErrorFinder { readonly extractors: CauseExtractor[]; constructor(extractors: ReadonlyArray); /** DFS on causes. */ private walk; find(root: unknown, fn: (e: unknown) => V | undefined): ErrorMatch | undefined; } export declare function errorCauseExtractor(err: unknown): ReadonlyArray | undefined; export declare function statusErrorCauseExtractor(err: unknown): ReadonlyArray | undefined; /** * Resets the list of global extractors used by `findError` and similar methods. * The default finder contains only the `libraryCauseExtractor`. This function * returns the previous extractors so that they can be restored. */ export declare function setCauseExtractors(newExtractors: ReadonlyArray): ReadonlyArray; /** Finds an error using the current list of global extractors. */ export declare function findError(root: unknown, fn: (err: unknown) => V | undefined): ErrorMatch | undefined; /** * Returns the first code contained by this error. This is useful for example to * "see through" status errors. */ export declare function findErrorCode(root: unknown): ErrorCode | undefined; /** * Minimal interface to allow passing both sets and maps as error code arguments * in `findErrorWithCode` and efficiently implement the corresponding check. */ export interface ErrorCodeCollection { has(code: ErrorCode): boolean; } /** Convenience method to find a internal error by code. */ export declare function findErrorWithCode(root: unknown, code: TaggedErrorCode): ErrorMatch, StandardError> | undefined; export declare function findErrorWithCode(root: unknown, code: ErrorCode | ErrorCodeCollection): ErrorMatch | undefined; /** * Returns a set with all error codes explicitly found in an error's causal * chain. Note that unlike with `errorCode`, implicit `ERR_INTERNAL` codes are * not added here. */ export declare function collectErrorCodes(root: unknown): ReadonlySet;