import { type Maybe } from '../value/maybe.type'; /** * Generic function that is meant to throw an error if the input is known. Returns void otherwise. */ export type ThrowErrorFunction = (error: T) => never | void; /** * A unique identifier for a specific error. * * @semanticType * @semanticTopic identifier * @semanticTopic string */ export type StringErrorCode = string; /** * Default error code used when no specific code is provided. */ export declare const DEFAULT_READABLE_ERROR_CODE = "ERROR"; /** * An error that is identified by a unique code. */ export interface CodedError { readonly code: StringErrorCode; /** * The original error, if available. */ readonly _error?: unknown; } /** * An error with a human-readable message. */ export interface ReadableError extends Partial { readonly message?: Maybe; } /** * Checks if the error has the default error code or no code at all. * * @param error - A ReadableError or error code string to check. * @returns True if the error uses the default code or has no code. */ export declare function isDefaultReadableError(error: Maybe): boolean; /** * A ReadableError that is guaranteed to have a code. */ export type ReadableErrorWithCode = T & CodedError; /** * Creates a ReadableError with a code and optional message. * * @param code - The error code. * @param message - Optional human-readable error message. * @returns A ReadableErrorWithCode object. */ export declare function readableError(code: StringErrorCode, message?: string): ReadableErrorWithCode; /** * A ReadableError that includes additional data of type T. */ export interface ReadableDataError extends ReadableError { readonly data?: T; } /** * Wrapper around an error that contains the error data. */ export interface ErrorWrapper { readonly data: ReadableError | CodedError; } /** * Union of all supported error input types for conversion functions. */ export type ErrorInput = ErrorWrapper | CodedError | ReadableError | ReadableDataError; /** * Converts various error input formats to a normalized ReadableErrorWithCode. * Handles CodedError, ErrorWrapper, BaseError, and plain ReadableError inputs. * * @param inputError - The error to convert * @returns A normalized ReadableErrorWithCode */ export declare function toReadableError(inputError: ErrorInput): CodedError | ReadableErrorWithCode; export declare function toReadableError(inputError: Maybe): Maybe; /** * Checks if an error's message contains the target string. * * @param input - Error-shaped value or message string to inspect; nullish short-circuits to false. * @param target - Substring that must appear in the resolved error message. * @returns True when the error message includes `target`. */ export declare function errorMessageContainsString(input: Maybe, target: string): boolean; /** * Function that checks if an error's message contains a specific string. */ export type ErrorMessageContainsStringFunction = (input: Maybe) => boolean; /** * Creates a function that checks if an error's message contains the target string. * * @param target - Substring that must appear in the resolved error message. * @returns Reusable predicate that yields true when the inspected error contains `target`. * * @dbxUtil * @dbxUtilCategory error * @dbxUtilKind factory * @dbxUtilTags error, message, contains, factory, predicate, regex * @dbxUtilRelated escape-string-for-regex * * @__NO_SIDE_EFFECTS__ */ export declare function errorMessageContainsStringFunction(target: string): ErrorMessageContainsStringFunction; /** * Extracts the message string from an error or returns the input if it's already a string. * * @param input - The error or string to extract a message from. * @returns The error message string, or null/undefined if not available. */ export declare function messageFromError(input: Maybe): Maybe;