export interface ErrorListenerCallback { (error: any): void; } export interface ErrorListenerUnbind { (): void; } export declare class ErrorHandler { private unexpectedErrorHandler; private listeners; constructor(); addListener(listener: ErrorListenerCallback): ErrorListenerUnbind; private emit; private _removeListener; setUnexpectedErrorHandler(newUnexpectedErrorHandler: (e: any) => void): void; getUnexpectedErrorHandler(): (e: any) => void; onUnexpectedError(e: any): void; onUnexpectedExternalError(e: any): void; } export declare const errorHandler: ErrorHandler; /** * This function should only be called with errors that indicate a bug in the product. * E.g. buggy extensions/invalid user-input/network issues should not be able to trigger this code path. * If they are, this indicates there is also a bug in the product. */ export declare function onBugIndicatingError(e: any): undefined; export declare function onUnexpectedError(e: any): undefined; export declare function onUnexpectedExternalError(e: any): undefined; export interface SerializedError { readonly $isError: true; readonly name: string; readonly message: string; readonly stack: string; readonly noTelemetry: boolean; readonly code?: string; readonly cause?: SerializedError; } export declare function transformErrorForSerialization(error: Error): SerializedError; export declare function transformErrorForSerialization(error: any): any; /** * Checks if the given error is a promise in canceled state */ export declare function isCancellationError(error: any): boolean; export declare class CancellationError extends Error { constructor(); } /** * @deprecated use {@link CancellationError `new CancellationError()`} instead */ export declare function canceled(): Error; export declare function illegalArgument(name?: string): Error; export declare function illegalState(name?: string): Error; export declare class NotSupportedError extends Error { constructor(message?: string); } /** * Error that when thrown won't be logged in telemetry as an unhandled error. */ export declare class ErrorNoTelemetry extends Error { readonly name: string; constructor(msg?: string); static fromError(err: Error): ErrorNoTelemetry; static isErrorNoTelemetry(err: Error): err is ErrorNoTelemetry; } /** * This error indicates a bug. * Do not throw this for invalid user input. * Only catch this error to recover gracefully from bugs. */ export declare class BugIndicatingError extends Error { constructor(message?: string); }