DittoError is a subclass of the default Javascript Error. You can identify specific errors programatically using the code property.

Please reference ERROR_CODES for a comprehensive list of possible error codes in this SDK version.

Handling a specific error code:

import { Attachment, DittoError } from '@dittolive/ditto'

let attachment: Attachment
try {
attachment = await ditto.store.newAttachment(filePath)
} catch (error) {
if (error instanceof DittoError && error.code === 'store/attachment-file-not-found') {
// Handle a non-existing file
}
throw error // Rethrow any other error
}

Hierarchy

  • Error
    • DittoError

Properties

Properties

code:
    | "internal"
    | "internal/unknown-error"
    | "sdk/unsupported"
    | "authentication/failed-to-authenticate"
    | "io/already-exists"
    | "io/not-found"
    | "io/permission-denied"
    | "io/operation-failed"
    | "query/arguments-invalid"
    | "query/execution"
    | "query/invalid"
    | "query/unsupported"
    | "query/parameter"
    | "store/backend"
    | "store/crdt"
    | "store/document-not-found"
    | "store/attachment-file-permission-denied"
    | "store/attachment-file-not-found"
    | "store/attachment-not-found"
    | "store/attachment-token-invalid"
    | "store/failed-to-create-attachment"
    | "store/failed-to-fetch-attachment"
    | "activation/license-token-verification-failed"
    | "activation/license-token-expired"
    | "activation/license-token-unsupported-future-version"
    | "activation/not-activated"
    | "validation/depth-limit-exceeded"
    | "validation/invalid-cbor"
    | "validation/invalid-json"
    | "validation/not-an-object"
    | "validation/not-json-compatible"
    | "validation/size-limit-exceeded"

Use the error code to identify a specific error programatically.

ERROR_CODES for a comprehensive list of possible error codes in this SDK version.

context: Readonly<ErrorContext>

Additional data, which provides context to the error and may help with debugging.

Warning: The contents of this object may change in future versions of the SDK.

stack?: string

Some environments provide a stack trace that is attached to any error.