@twilio/flex-ui
Version:
Twilio Flex UI
232 lines (231 loc) • 7.51 kB
TypeScript
import { Config } from "./state/AppConfig";
/**
* FlexError types
* @category Flex Errors
* @ignore
* @enum {"app" | "chatSDK" | "syncSDK" | "taskrouterSDK" | "voiceSDK"} FlexErrorType
* @property {"app"} app - Errors originating from Flex UI
* @property {"chatSDK"} chatSDK - Errors originating from Chat SDK
* @property {"syncSDK"} syncSDK - Errors originating from Sync SDK
* @property {"taskrouterSDK"} taskrouterSDK - Errors originating from Taskrouter SDK
* @property {"flexSDK"} flexSDK - Errors originating from Flex SDK
* @property {"voiceSDK"} voiceSDK - Errors originating from Voice SDK
* @property {"cbmSDK"} cbmSDK - Errors originating from CBM SDK
* @memberof FlexError
*/
export declare enum FlexErrorType {
app = "app",
chatSDK = "chatSDK",
syncSDK = "syncSDK",
taskrouterSDK = "taskrouterSDK",
flexSDK = "flexSDK",
voiceSDK = "voiceSDK",
cbmSDK = "cbmSDK",
flexUnify = "flexUnify",
segment = "segment"
}
/**
* FlexError severity
* @category Flex Errors
* @ignore
* @enum {"user" | "normal" | "severe" } FlexErrorSeverity
* @property {"user"} user - Errors originating from denial to user request, not actual error
* @property {"normal"} normal - Normal error condition
* @property {"severe"} severe - Severe error condition (some system hard down)
* @memberof FlexError
*/
export declare enum FlexErrorSeverity {
user = "user",
normal = "normal",
severe = "severe"
}
/**
* FlexError codes
* @category Flex Errors
* @ignore
* @enum {45600 | 45601 | 45004 | 45002 | 45050} TwilioErrorCodes
* @property {45600} FlexError - Error code indicating Flex UI context
* @property {45601} CustomFlexError - Error code indicating custom Flex UI context
* @property {45004} ValidationError - Error code indicating request body validation errors
* @property {45002} AuthenticationError - Error code indicating invalid credentials
* @property {45050} AuthenticationErrorSSOv2 - Error code related to SSOv2 authentication
* @memberof FlexError
*/
export declare enum TwilioErrorCodes {
FlexError = 45600,
CustomFlexError = 45601,
ValidationError = 45004,
AuthenticationError = 45002,
AuthenticationErrorSSOv2 = 45050
}
/**
* Information about the plugin
* @category Flex Errors
* @ignore
* @typedef PluginInfo
* @property {string} [name] Name of the plugin
* @property {string} [version] Version of the plugin
* @memberof FlexError
*/
export type PluginInfo = {
name?: string;
version?: string;
};
/**
* Flex Error Content
* @category Flex Errors
* @ignore
* @typedef FlexErrorContents
* @property {FlexErrorType} [type] Type of the error
* @property {Error} [wrappedError] The original error
* @property {FlexError.PluginInfo} [plugin] Information about the plugin where the error occured (if applicable)
* @property {string} [context] Error context, including theme customizations
* @property {string} [description] Longer and more verbose description of the error than message property, possibly with variable metadata
* @property {FlexErrorSeverity} [severity] Severity level of the error
* @memberof ErrorManager
*/
export type FlexErrorContents = {
type?: FlexErrorType;
wrappedError?: Error | string | unknown;
plugin?: PluginInfo;
context?: string;
description?: string;
severity?: FlexErrorSeverity;
twilioErrorCode?: TwilioErrorCodes;
module?: string;
};
/**
* Information about the session where the error occured
* @category Flex Errors
* @ignore
* @typedef SessionData
* @property {Config} [config] Session configuration
* @property {string} [reactVersion] React version
* @property {string} [bundleType] Bundle type
* @memberof FlexError
*/
export type SessionData = {
config?: Config;
reactVersion?: string;
bundleType?: string;
plugins?: {
name: string;
}[];
userAgent?: string;
};
/**
* @category Flex Errors
* @class FlexError
* @menuorder 100
* @hideconstructor
* @extends Error
* @classdesc The FlexError class is an extension of a normal JavaScript Error class, with added context. This class includes more info on errors to help pinpoint problems and consolidate the Flex UI API.
* You can learn more about [troubleshooting Flex UI here](https://www.twilio.com/docs/flex/developer/ui/troubleshooting-the-flex-ui)
*/
export declare class FlexError extends Error {
/**
* Flex content
* @type {FlexErrorContents}
*/
content: FlexErrorContents & {
type: FlexErrorType;
severity: FlexErrorSeverity;
twilioErrorCode: TwilioErrorCodes;
};
/**
* Session data
* @type {FlexError.SessionData}
*/
sessionData: SessionData;
/**
* Whether or not the error should be sent to Twilio Debugger
*
* @type {boolean | undefined}
* @private
*/
debuggerIntegrationEnabled: boolean | undefined;
/**
* Sid of resource associated with error (workspace sid)
*
* @type {string | undefined}
* @private
*/
resourceSid: string | undefined;
/**
* Date when the error has been triggered
* @type {Date}
*/
time: Date;
/**
* Code area, module or component that reported the error
* @type {string | undefined}
*/
module: string | undefined;
/**
* Timestamp related with the latest relevant log
* @type {string | undefined}
*/
logManagerTimestamp: string | undefined;
constructor(message: string, content?: FlexErrorContents);
private getLogTime;
/**
* type, indicating what part of the FlexUI caused the issue, the library itself or any of the sdks
* @type {FlexErrorType}
*/
get type(): FlexErrorType | undefined;
/**
* gets you the logs associated with this Flex error.
* @type {string}
*/
get logs(): string;
/**
* Represents log line
* @type {string}
*/
get logLine(): string;
}
export declare const isFlexError: (e: unknown) => e is FlexError;
declare class ErrorManagerImpl {
sessionData: {};
private handleCoreError;
private ErrorSeverityFromCoreErrorSeverity;
private ErrorTypeFromCoreErrorType;
constructor();
/**
* @private
*/
updateSessionData(sessionData: SessionData): void;
/**
* Processes a FlexError
* @name processError
* @function
* @param {FlexError} error Error to be processed
* @returns {FlexError} The processed error
* @memberof ErrorManager
* @example
* ErrorManager.processError(new FlexError("no connection", {description: "There was no internet connection"})); // creates and processes an error
*/
processError(error: FlexError): FlexError;
/**
* Creates and processes a FlexError
* @name createAndProcessError
* @function
* @param {string} message message field of FlexError
* @param {FlexErrorContents} content part of FlexError
* @returns {FlexError} An instance of FlexError
* @memberof ErrorManager
* @example
* ErrorManager.createAndProcessError( "no connection", {description: "There was no internet connection", context:"some context"});
*/
createAndProcessError(message: string, content?: FlexErrorContents): FlexError;
}
/**
* @class ErrorManager
* @hideconstructor
* @category Flex Errors
*/
export declare const ErrorManager: ErrorManagerImpl;
export interface FlexErrorTrace extends FlexError {
flowName: string;
}
export {};