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:
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)
Code
Domain
Reason
Sent to global delegate
1100
INITIALIZATION
INVALID_API_KEY
Yes
1101
INITIALIZATION
NETWORK_FAILURE
Yes
1102
INITIALIZATION
SDK_ALREADY_INITIALIZED
Yes
1103
INITIALIZATION
APPLICATION_NOT_INITIALIZED
No
1104
INITIALIZATION
INVALID_GEO_RESTRICTION_CODE
Yes
1105
INITIALIZATION
NO_INTERNET_CONNECTION
Yes
1106
INITIALIZATION
INVALID_APP_CONFIG
Yes
1107
INITIALIZATION
TIME_OUT
Yes
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)
Code
Domain
Reason
Sent to global delegate
1200
CONTENT_PREPARATION
ILLEGAL_PREPARE_ON_DATA_SOURCE_TYPE
Yes
Widget errors (1300-1399)
Code
Domain
Reason
Sent to global delegate
1300
WIDGET
NO_AVAILABLE_CONTENT_FOR_DATA_SOURCE
No
1301
WIDGET
INVALID_DATA_SOURCE_TYPE_PROVIDED
Yes
1302
WIDGET
FAILED_FETCHING_CONTENT
Yes
1303
WIDGET
EMPTY_TABS_CONFIGURATION
Yes
Entry point errors (1400-1499)
Code
Domain
Reason
Sent to global delegate
1400
ENTRY_POINT
NO_AVAILABLE_CONTENT_FOR_DATA_SOURCE
Yes
1401
ENTRY_POINT
INVALID_DATA_SOURCE_TYPE_PROVIDED
Yes
1402
ENTRY_POINT
FAILED_FETCHING_CONTENT
Yes
1403
ENTRY_POINT
FAILED_PLAYING_STORY
Yes
1404
ENTRY_POINT
FAILED_PLAYING_MOMENT
Yes
1405
ENTRY_POINT
FAILED_PLAYING_VIDEO
Yes
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)
Code
Domain
Reason
Sent to global delegate
1505
PLAYER
NO_INTERNET_CONNECTION
Yes
1506
PLAYER
EXPIRED_ASSET
Yes
1507
PLAYER
FAILED_TO_LOAD_IMAGE_ASSET
Yes
1508
PLAYER
FAILED_TO_LOAD_VIDEO_ASSET
Yes
User management errors (1600-1699)
Code
Domain
Reason
Sent to global delegate
1609
USER_MANAGEMENT
FAILED_TO_SET_EXTERNAL_USER_ID
No
1611
USER_MANAGEMENT
INVALID_EXTERNAL_USER_ID
No
1612
USER_MANAGEMENT
FAILED_TO_LOGOUT
No
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.