import { AjaxSettings, DoEntity, InitModelOf, LogLevel, MessageBox, MessageBoxActionEvent, ModelOf, ObjectModel, ObjectWithType, Session, Status, StatusSeverity } from './index';
export interface ErrorHandlerModel extends ObjectModel<ErrorHandler> {
    /**
     * Default is true
     */
    logError?: boolean;
    /**
     * Default is true
     */
    displayError?: boolean;
    /**
     * Default is false
     */
    sendError?: boolean;
    session?: Session;
}
export interface ErrorInfo {
    /**
     * The original error. May be Error, AjaxError or any other type like string, number etc. since any object can be thrown.
     */
    error?: any;
    /**
     * Specifies if the error should be shown as fatal error or not.
     * If true, a fatal error is shown which forces the user to reload the page (unless in dev mode where it can be ignored).
     * If false, a normal messagebox with an ok button is shown and after confirmation the user is allowed to use the app again without reload.
     * The default is false.
     */
    showAsFatalError?: boolean;
    /**
     * The message of the error
     */
    message?: string;
    /**
     * The error code
     */
    code?: string;
    /**
     * The HTTP status code if the error comes from an HTTP request
     */
    httpStatus?: number;
    /**
     * If the error contains an ErrorDo (see ErrorDo.java)
     */
    errorDo?: ErrorDo;
    /**
     * The original stack trace
     */
    stack?: string;
    /**
     * Sourcemapped stack trace
     */
    mappedStack?: string;
    /**
     * If there stacktrace mapping to source-maps fails this field contains the cause.
     */
    mappingError?: string;
    /**
     * The full message to log. Typically consists of the message and e.g. a stack trace.
     */
    log?: string;
    /**
     * Specifies the level errors are logged to the console (and sent to the backend for logging). Default is {@link LogLevel.ERROR}.
     */
    level?: LogLevel;
    /**
     * Additional custom debug info. May come from an extra field on an Error thrown (Scout extension) or the response text from an ajax call.
     */
    debugInfo?: string;
}
/**
 * See org.eclipse.scout.rt.rest.error.ErrorDo
 */
export interface ErrorDo extends DoEntity {
    httpStatus?: number;
    errorCode?: string;
    title?: string;
    message?: string;
    correlationId?: string;
    severity?: string;
}
export declare class ErrorHandler implements ErrorHandlerModel, ObjectWithType {
    model: ErrorHandlerModel;
    objectType: string;
    logError: boolean;
    displayError: boolean;
    sendError: boolean;
    session: Session;
    windowErrorHandler: OnErrorEventHandlerNonNull;
    constructor();
    /**
     * Use this constant to configure whether all instances of the ErrorHandler should write
     * to the console. When you've installed a console appender to log4javascript you can set the
     * value to false, because the ErrorHandler also calls $.log.error and thus the appender has
     * already written the message to the console. We don't want to see it twice.
     */
    static CONSOLE_OUTPUT: boolean;
    init(options?: InitModelOf<this>): void;
    protected _onWindowError(errorMessage: string, fileName?: string, lineNumber?: number, columnNumber?: number, error?: Error): void;
    protected _isIgnorableScriptError(message: string, fileName?: string, lineNumber?: number, columnNumber?: number, error?: Error): boolean;
    /**
     * Handles unexpected JavaScript errors. The arguments are first analyzed and then handled.
     *
     * This method may be called by passing the arguments individually or as an array (or array-like object)
     * in the first argument.
     * Examples:
     *   1. try { ... } catch (err) { handler.handle(err); }
     *   2. $.get().fail(function(jqXHR, textStatus, errorThrown) { handler.handle(jqXHR, textStatus, errorThrown); }
     *   3. $.get().fail(function(jqXHR, textStatus, errorThrown) { handler.handle(arguments); } // <-- recommended
     *
     * @param errorOrArgs error or array or array-like object containing the error and other arguments
     * @returns the analyzed errorInfo
     */
    handle(errorOrArgs: any | IArguments | any[], ...args: any[]): JQuery.Promise<ErrorInfo>;
    /**
     * Returns an "errorInfo" object for the given arguments. The following cases are handled:
     * 1. Error objects           (code: computed by getJsErrorCode())
     * 2. jQuery AJAX errors      (code: 'X' + HTTP status code)
     * 3. Nothing                 (code: 'P3')
     * 4. Everything else         (code: 'P4')
     */
    analyzeError(error?: any, ...args: any[]): JQuery.Promise<ErrorInfo>;
    protected _analyzeError(errorInfo: ErrorInfo, ...args: any[]): JQuery.Promise<ErrorInfo>;
    protected _analyzeRegularError(errorInfo: ErrorInfo): void;
    protected _analyzeAjaxError(errorInfo: ErrorInfo, ...args: any[]): void;
    formatAjaxStatus(jqXHR: JQuery.jqXHR, errorThrown: string): string;
    formatAjaxRequest(requestOptions: AjaxSettings): string;
    protected _severityToLogLevel(severity: string): LogLevel;
    protected _analyzeOtherError(errorInfo: ErrorInfo): void;
    protected _analyzeNoError(errorInfo: ErrorInfo): void;
    mapStack(stack: string): JQuery.Promise<string, {
        message: string;
        error: Error;
    }>;
    /**
     * Expects an object as returned by {@link analyzeError} and handles it:
     * - If the flag "logError" is set, the log message is printed to the console
     * - If there is a scout session and the flag "displayError" is set, the error is shown in a message box.
     * - If there is a scout session and the flag "sendError" is set, the error is sent to the UI server.
     */
    handleErrorInfo(errorInfo: ErrorInfo): JQuery.Promise<ErrorInfo>;
    protected _logErrorInfo(errorInfo: ErrorInfo): void;
    /**
     * Generate a "cool looking" error code from the JS error object, that
     * does not reveal too much technical information, but at least indicates
     * that a JS runtime error has occurred. (In contrast, fatal errors from
     * the server have numeric error codes.)
     */
    getJsErrorCode(error?: Error): string;
    protected _showErrorMessageBox(session: Session, errorInfo: ErrorInfo): JQuery.Promise<MessageBoxActionEvent>;
    protected _buildErrorMessageBoxModel(session: Session, errorInfo: ErrorInfo): ModelOf<MessageBox>;
    protected _showInternalUiErrorMessageBox(session: Session, errorMessage: string, errorCode: string, logMessage: string): JQuery.Promise<void>;
    protected _sendErrorMessage(session: Session, logMessage: string, logLevel: LogLevel): void;
    errorInfoToStatus(session: Session, errorInfo: ErrorInfo): Status;
    protected _errorInfoToStatusCode(errorInfo: ErrorInfo): number;
    protected _errorInfoToStatusSeverity(errorInfo: ErrorInfo): StatusSeverity;
    protected _errorInfoToStatusMessage(session: Session, errorInfo: ErrorInfo): string;
    /**
     * Gets the default error message body for the given HTTP status error code.
     * @param httpStatus The HTTP status error code. E.g. 503 (Service Unavailable)
     * @param session An optional Session for a message in the language of the user. The default language is used if omitted.
     * @returns The error message for the given error HTTP status.
     */
    getMessageBodyForHttpStatus(httpStatus: number, session?: Session): string;
}
//# sourceMappingURL=ErrorHandler.d.ts.map