import { SyncBailHook } from "tapable-ts"; import type { Logger } from "../../logger"; import type { DataController } from "../data/controller"; import type { FlowController } from "../flow/controller"; import type { PlayerError } from "./types"; import { ErrorStateMiddleware } from "./middleware"; export interface ErrorControllerHooks { /** * Fired when any error is captured * - Called in order for each tapped plugin * - Return true to bail and prevent error state navigation * - Return undefined/false to continue to next handler * - Once true is returned, no further plugins are called */ onError: SyncBailHook<[PlayerError], boolean | undefined>; } export interface ErrorControllerOptions { /** Logger for error operations */ logger: Logger; /** Flow controller for error navigation */ flow: FlowController; /** Callback to fail/reject the flow */ fail: (error: Error) => void; /** Data model for setting errorState (can be set later via setOptions) */ model?: DataController; } /** The orchestrator for player error handling */ export declare class ErrorController { hooks: ErrorControllerHooks; private options; private readonly middleware; /** * Complete history of all captured errors in chronological order * Newest errors are APPENDED to the end of the array */ private errorHistory; private currentError?; constructor(options: ErrorControllerOptions); /** * Get the middleware for protecting errorState * This should be added to DataController's middleware array */ getDataMiddleware(): ErrorStateMiddleware; /** * Set the DataController after initialization */ setOptions(options: Pick): void; /** * Capture an error and try to recover. Errors implementing the `PlayerErrorMetadata` interface will be added to history, fire hooks and update data model. As a fallback, all errors will try to trigger an errorTransition. If the error does not have a `type` property, it will default to only using the wildcard navigation. */ captureError(error: Error): boolean; /** * Navigate to error state using errorTransitions. * Uses errorTransition() which handles node-level and flow-level fallback internally. */ private tryNavigateToErrorState; /** * Get most recent error */ getCurrentError(): PlayerError | undefined; /** * Get error history (read-only) */ getErrors(): ReadonlyArray; /** * Clear all errors (history + current + data model) */ clearErrors(): void; /** * Clear only current error and remove from data model, preserve history */ clearCurrentError(): void; /** * Write error to data model errorState */ private setErrorInDataModel; /** * Remove errorState from data model */ private deleteErrorFromDataModel; } //# sourceMappingURL=controller.d.ts.map