Skip to main content

SDKError

The SDK's structured error class. Thrown or passed to TFrameEvents.onAppError whenever the SDK encounters a known failure.

The code property identifies the failure category; recoverable indicates whether the caller may retry the operation without reinitializing the frame. For SDKErrorCode.ApiError the status and data properties carry what the portal reported.

Example​

import { SDKError, SDKErrorCode } from '@onlyoffice/docspace-sdk-js';

instance.getFiles().catch((err) => {
if (err instanceof SDKError) {
console.error(`[${err.code}] ${err.message}`);
if (err.recoverable) {
scheduleRetry();
}
}
});

Extends​

  • Error

Constructors​

Constructor​

new SDKError(
code: SDKErrorCode,
message: string,
recoverable?: boolean,
details?: TSDKErrorDetails
): SDKError;

Parameters​

ParameterTypeDefault valueDescription
codeSDKErrorCodeundefinedThe error category. Use a SDKErrorCode value.
messagestringundefinedHuman-readable description of what went wrong.
recoverablebooleanfalseWhether the operation may be retried. Default: false.
detailsTSDKErrorDetailsundefinedHTTP status and portal payload for SDKErrorCode.ApiError. See TSDKErrorDetails.

Returns​

SDKError

Overrides​

Error.constructor

Properties​

PropertyModifierTypeDescription
codereadonlySDKErrorCodeThe error category. One of the SDKErrorCode string values. Use this for programmatic branching rather than parsing message.
datareadonlyobjectThe portal's error payload for SDKErrorCode.ApiError, with config, request and stack removed; undefined for every other code.
recoverablereadonlybooleanWhether the caller can retry the failed operation without reinitializing the frame. Default: false.
statusreadonlynumberHTTP status of the failed portal request. Set for SDKErrorCode.ApiError when the portal reported one; undefined otherwise.