Errors - Android

The Experiences SDK provides structured and consistent error information through the BlazeResult.Error type. Errors can be delivered globally through the SDK delegate, locally through method completion handlers, or through source delegates for widgets, containers, and entry points, depending on the context.

Error structure

The BlazeResult.Error data class represents the public-facing error structure returned by the Experiences SDK.

data class Error(
    val statusCode: Int? = null,
    var domain: ErrorDomain? = null,
    var reason: ErrorReason? = null,
    var message: String? = null,
    var metadata: Map<String, String> = emptyMap(),
    var cause: Exception? = null
)
  • statusCode: the error code from the tables below (for example, 1100), or null when the error has no code. Errors delivered through onDataLoadComplete, and some errors returned to method completion handlers (for example, from playStory or handleUniversalLink), have no code, so check for null before you use it.
  • domain: the domain or category of the error, or null.
  • reason: the specific reason for the error, or null.
  • message: a human-readable error message, or null.
  • metadata: additional metadata related to the error. Defaults to an empty map.
  • cause: the underlying exception that caused the error, if any.

Error delivery mechanisms

1. BlazeSDKDelegate

Errors marked Yes in the Sent to global delegate column of the tables below are forwarded to the onErrorThrown callback of your BlazeSDKDelegate implementation.

// Example of handling error via BlazeSDKDelegate
private fun createBlazeSDKGlobalDelegate(): BlazeSDKDelegate {
    return object : BlazeSDKDelegate {
        override fun onEventTriggered(eventData: BlazeAnalyticsEvent) {
            onGlobalEventTriggered(eventData)
        }
        
        override fun onErrorThrown(error: BlazeResult.Error) {
            onGlobalErrorThrown(error)
        }
    }
}

private fun onGlobalErrorThrown(error: BlazeResult.Error) {
    // Handle specific error domains and reasons
    when (error.domain) {
        ErrorDomain.INITIALIZATION -> {
            handleInitializationError(error)
        }
        ErrorDomain.WIDGET -> {
            handleWidgetError(error)
        }
        else -> {
            // Handle other domains
        }
    }
}

2. Completion handlers

Some errors are returned only through completion handlers for specific API calls (for example, some initialization errors, setting the external user ID, logging out, and some universal link errors). In these cases, handle errors in the callback, because it's the only place you receive them.

// Error should be handled via completion callback
BlazeSDK.init(
    apiKey = "your-api-key",
    completionBlock = {
        Log.d("Application", "BlazeSDK.init success completionBlock..")
    },
    errorBlock = { error ->
        Log.e("Application", "BlazeSDK.init: errorBlock: Init Error = $error")
        when (error.reason) {
            ErrorReason.INVALID_API_KEY -> {
                Log.e("Application", "BlazeSDK.init: errorBlock: Invalid API Key")
            }
            ErrorReason.SDK_ALREADY_INITIALIZED -> {
                Log.e("Application", "BlazeSDK.init: errorBlock: SDK Already Initialized")
            }
            else -> {} // Handle other error reasons as needed
        }

    },
)

3. Source delegates

Component-specific errors are delivered through the onDataLoadComplete handler of each source delegate:

  • BlazeWidgetDelegate: widget load errors.
  • BlazePlayerInContainerDelegate: container load errors.
  • BlazePlayerInInlineDelegate: inline player load errors.
  • BlazePlayerContainerTabsDelegate: container tabs load errors.
  • BlazePlayerEntryPointDelegate: entry point load errors.
val widgetDelegate: BlazeWidgetDelegate = object : BlazeWidgetDelegate {

    override fun onDataLoadStarted(playerType: BlazePlayerType, sourceId: String?) {
        // handle onDataLoadStarted
    }

    override fun onDataLoadComplete(
        playerType: BlazePlayerType,
        sourceId: String?,
        itemsCount: Int,
        result: BlazeResult<Unit>
    ) {
        when (result) {
            is BlazeResult.Success -> {
                // Handle successful load
            }
            is BlazeResult.Error -> {
                handleWidgetError(result)
            }
        }
    }
}

Error codes

Errors that aren't listed here, such as unexpected errors, arrive with only a domain (for example, GENERAL) and no statusCode or reason.

Initialization errors (1100-1199)

CodeDomainReasonSent to global delegate
1100INITIALIZATIONINVALID_API_KEYYes
1101INITIALIZATIONNETWORK_FAILUREYes
1102INITIALIZATIONSDK_ALREADY_INITIALIZEDYes
1103INITIALIZATIONAPPLICATION_NOT_INITIALIZEDNo
1104INITIALIZATIONINVALID_GEO_RESTRICTION_CODEYes
1105INITIALIZATIONNO_INTERNET_CONNECTIONYes
1106INITIALIZATIONINVALID_APP_CONFIGYes
1107INITIALIZATIONTIME_OUTYes

The global delegate receives initialization errors only after init sets it. A blank API key (INVALID_API_KEY) and a repeated call (SDK_ALREADY_INITIALIZED) are checked before that, so these errors reach only a delegate that an earlier init call set. errorBlock always receives errors from init.

Content preparation errors (1200-1299)

CodeDomainReasonSent to global delegate
1200CONTENT_PREPARATIONILLEGAL_PREPARE_ON_DATA_SOURCE_TYPEYes

Widget errors (1300-1399)

CodeDomainReasonSent to global delegate
1300WIDGETNO_AVAILABLE_CONTENT_FOR_DATA_SOURCENo
1301WIDGETINVALID_DATA_SOURCE_TYPE_PROVIDEDYes
1302WIDGETFAILED_FETCHING_CONTENTYes
1303WIDGETEMPTY_TABS_CONFIGURATIONYes

Entry point errors (1400-1499)

CodeDomainReasonSent to global delegate
1400ENTRY_POINTNO_AVAILABLE_CONTENT_FOR_DATA_SOURCEYes
1401ENTRY_POINTINVALID_DATA_SOURCE_TYPE_PROVIDEDYes
1402ENTRY_POINTFAILED_FETCHING_CONTENTYes
1403ENTRY_POINTFAILED_PLAYING_STORYYes
1404ENTRY_POINTFAILED_PLAYING_MOMENTYes
1405ENTRY_POINTFAILED_PLAYING_VIDEOYes

Some failures in this domain are returned only to the completion handler, for example, NO_AVAILABLE_CONTENT_FOR_DATA_SOURCE when a data source returns no content.

Player errors (1500-1599)

CodeDomainReasonSent to global delegate
1505PLAYERNO_INTERNET_CONNECTIONYes
1506PLAYEREXPIRED_ASSETYes
1507PLAYERFAILED_TO_LOAD_IMAGE_ASSETYes
1508PLAYERFAILED_TO_LOAD_VIDEO_ASSETYes

User management errors (1600-1699)

CodeDomainReasonSent to global delegate
1609USER_MANAGEMENTFAILED_TO_SET_EXTERNAL_USER_IDNo
1611USER_MANAGEMENTINVALID_EXTERNAL_USER_IDNo
1612USER_MANAGEMENTFAILED_TO_LOGOUTNo

Codes 1611 (INVALID_EXTERNAL_USER_ID) and 1612 (FAILED_TO_LOGOUT) are available starting with Experiences SDK 2.0.1. Earlier versions don't return them. Calling logout before init, or after a failed init, returns APPLICATION_NOT_INITIALIZED (1103) to the completion handler.

Universal link errors (1700-1799)

CodeDomainReasonSent to global delegate
1700UNIVERSAL_LINKINVALID_LINKYes
1701UNIVERSAL_LINKINVALID_DOMAINYes
1702UNIVERSAL_LINKFAILED_HANDLING_UNIVERSAL_LINKNo

Push notification errors (1800-1899)

CodeDomainReasonSent to global delegate
1800PUSHINVALID_NOTIFICATION_EXTRAS_SCHEMEYes
1801PUSHINVALID_NOTIFICATION_BODY_SCHEMEYes

Container errors (1900-1999)

CodeDomainReasonSent to global delegate
1900CONTAINERFAILED_PLAYING_CONTENT_CONTAINERYes
1901CONTAINERINVALID_DATA_SOURCE_TYPE_PROVIDEDYes
1902CONTAINERLIFECYCLE_OWNER_NOT_PROVIDEDYes
1903CONTAINERVIEW_MODEL_STORE_OWNER_NOT_PROVIDEDYes
1904CONTAINERCONTENT_PREPARATION_FAILEDYes
1905CONTAINERILLEGAL_PREPARE_ON_DATA_SOURCE_TYPEYes
1906CONTAINERFAILED_ADDING_PLACEHOLDER_CONTAINERYes
1907CONTAINERFAILED_ADDING_PLAYER_CONTAINERYes

Sharing errors (2100-2199)

CodeDomainReasonSent to global delegate
2100SHARINGFAILED_LAUNCHING_SHARE_INTENTYes
2101SHARINGFAILED_CREATING_LINKYes

Container tabs errors (2200-2299)

CodeDomainReasonSent to global delegate
2200CONTAINER_TABSDUPLICATE_CONTAINER_IDYes

Playback configuration errors (2300-2399)

CodeDomainReasonSent to global delegate
2300PLAYBACK_CONFIGURATIONSINVALID_LOOP_AND_ADVANCE_CONFIGURATIONYes

Picture-in-picture errors (2400-2499)

CodeDomainReasonSent to global delegate
2400PIPFAILED_TO_ENTER_PIPYes

Did this page help you?