Error documentation - iOS
BlazeSDK provides structured and consistent error information through the BlazeError type. Errors can be delivered globally via the SDK delegate, locally via method completion handlers, or via source delegates for widgets, entryPoints, etc., depending on the context.
Error Structure
public struct BlazeError: Error, Equatable {
public let domain: ErrorDomain
public let errorMessage: String
public let statusCode: Int
public let metadata: [String: String]
public let underlyingError: Error?
}domain: Categorizes the error (e.g.,.initialization,.widget, etc.)errorMessage: Human-readable description of the issuestatusCode: Unique numeric identifier for the errormetadata: Optional contextual info (e.g., data source type)underlyingError: The low-level error that caused this issue, if available
✅ You can inspect underlyingError to access the original system or network error (e.g., decoding failure, URL error).
Error Delivery Mechanisms
1. BlazeSDKDelegate
Errors marked as 'Thrown to Global Delegate' in the table below are automatically forwarded to your BlazeSDKDelegate implementation via the onErrorThrown callback.
// Example of handling error via BlazeSDKDelegate
private func createBlazeSDKGlobalDelegate() -> BlazeSDKDelegate {
return BlazeSDKDelegate { [weak self] eventData in
self?.onEventTriggered(eventData: eventData)
} onErrorThrown: { [weak self] error in
self?.onErrorThrown(error)
}
}
func onErrorThrown(_ error: BlazeError) {
// Handle specific error domains and reasons
switch error.domain {
case .initialization(let reason):
handleInitializationError(reason)
case .widget(let reason):
handleWidgetError(reason)
default:
break
}
}
Blaze.shared.delegate = createBlazeSDKGlobalDelegate()2. Completion Handlers
Some errors are returned only through completion handlers for specific API calls (e.g., initialization, setting user ID, universal link processing). Therefore, in these cases, you should handle errors exclusively in the callback, as this is the only way to properly catch and respond to them.
// Error should be handled via completion block
Blaze.shared.initialize(
apiKey: "your-api-key",
externalUserId: "user123"
) { result in
switch result {
case .success:
break
case .failure(let error):
// Handle specific error domains and reasons
if case .initialization(let reason) = error.domain {
switch reason {
case .invalidApiKey:
print("Invalid API key")
case .alreadyInitialized:
print("SDK is already initialized")
default:
break
}
}
}
}3. Source Delegates
Component-specific errors are delivered via source delegate onDataLoadComplete handlers for widgets, containers, and entry points:
- BlazeWidgetDelegate → Widget load errors via
onDataLoadCompletehandler - BlazePlayerContainerDelegate → Container load errors via
onDataLoadCompletehandler - BlazeInlinePlayerDelegate → Inline player load errors via
onDataLoadCompletehandler - BlazePlayerEntryPointDelegate → Entry point load errors via
onDataLoadCompletehandler
// Example of handling error via widget delegate
widget.delegate = BlazeWidgetDelegate { [weak self] eventData in
self?.onEventTriggered(eventData: eventData)
} onDataLoadComplete: { [weak self] result in
switch result {
case .success:
break
case .failure(let error):
self?.handleWidgetError(error)
}
}Notes
- ✅ All errors marked with ✅ Yes are forwarded to the global delegate.
- ⚠️ Some internal SDK issues are exposed via
.generalwith unexpected reason to simplify surface-level error handling. - 🛠 If needed, use
underlyingErrorfor deeper debugging or analytics.
Error Codes
General Errors (1000–1099)
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1000 | general | unexpected | ✅ Yes |
Initialization Errors (1100–1199)
These errors are delivered via theBlaze.shared.initialize() completion handler.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1100 | initialization | invalidApiKey | ❌ No |
| 1102 | initialization | alreadyInitialized | ❌ No |
| 1103 | initialization | initializationRequired | ❌ No |
| 1104 | initialization | invalidGeoCode | ❌ No |
| 1105 | initialization | sdkInitializationFailed | ❌ No |
| 1106 | initialization | fetchingAppConfigFailed | ❌ No |
| 1107 | initialization | unexpected | ❌ No |
Content Preparation Errors (1200–1299)
These errors are delivered viaprepareStories/prepareMoments/prepareVideos() completion handlers.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1200 | contentPreparation | noResultsForDataSourceType | ❌ No |
| 1201 | contentPreparation | invalidDataSourceType | ❌ No |
Widget Errors (1300–1399)
These errors are delivered via widget completion handlers and delegates.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1300 | widget | invalidDataSourceType | ❌ No |
| 1302 | widget | sdkInitializationError | ❌ No |
| 1303 | widget | failedUpdatingLike | ❌ No |
| 1305 | widget | unexpected | ❌ No |
Entry Point Errors (1400–1499)
These errors are delivered viaplayStories/playMoments/playVideos() completion handlers.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1400 | entryPoint | noResultsForDataSourceType | ❌ No |
| 1401 | entryPoint | invalidDataSourceType | ❌ No |
| 1403 | entryPoint | failedToUpdateLike | ❌ No |
| 1404 | entryPoint | unexpected | ❌ No |
User Management Errors (1500–1599)
These errors are delivered viasetExternalUserId() completion handlers.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1500 | userManagement | settingExternalIdFailed | ❌ No |
| 1501 | userManagement | invalidApiKey | ❌ No |
| 1506 | userManagement | unexpected | ❌ No |
Universal Link Errors (1600–1699)
These errors are delivered viahandleUniversalLink() completion handlers.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1600 | universalLink | invalidURL | ❌ No |
Notification Extra Info Errors (1700–1799)
These errors are delivered via notification handling completion handlers.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1700 | notificationExtraInfo | invalidExtraInfoScheme | ❌ No |
Data Source Errors (1900–1999)
These errors occur during internal data source operations.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 1900 | general | invalidDataSourceTypeProvided | ❌ No |
Content Errors (2000–2099)
These errors occur during internal content operations.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 2000 | general | fetchingContentFailed | ❌ No |
| 2001 | general | contentIsGeoRestricted | ❌ No |
Asset Errors (2100–2199)
These errors occur during asset loading operations.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 2100 | general | assetExpired | ✅ Yes |
| 2101 | general | videoAssetLoadingFailed | ✅ Yes |
Storage Errors (2200–2299)
These errors occur during internal storage operations.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 2200 | general | failedToSaveData | ❌ No |
Playback Errors (2400–2499)
These errors occur during media playback operations.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 2400 | general | videoPlaybackFailed | ✅ Yes |
| 2401 | general | imagePlaybackFailed | ✅ Yes |
| 2402 | general | connectivityIssue | ✅ Yes |
Image Loading Errors (2500–2599)
These errors occur during image loading operations.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 2500 | general | thumbnailLoadingFailed | ✅ Yes |
| 2501 | general | placeholderLoadingFailed | ✅ Yes |
Sharing Errors (2600–2699)
These errors occur during content sharing operations.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 2600 | general | sharingFailed | ✅ Yes |
| 2601 | general | shareConfigurationMissing | ✅ Yes |
Direct Media Errors (2700–2799)
These errors are delivered via play method completion handlers when feature is active.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 2700 | general | directMediaSourceIsInvalidForRequest | ✅ Yes |
| 2701 | general | directMediaSourceIsInvalidForStories | ✅ Yes |
| 2702 | general | directMediaSourceIsInvalidForMoments | ✅ Yes |
Playback Configuration Errors (2800–2899)
These errors occur during playback configuration operations.
| Code | Domain | Reason | Thrown to Global Delegate |
|---|---|---|---|
| 2800 | general | invalidLoopAndAdvanceConfiguration | ✅ Yes |
Updated 11 days ago
