GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

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 issue
  • statusCode: Unique numeric identifier for the error
  • metadata: 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 onDataLoadComplete handler
  • BlazePlayerContainerDelegate → Container load errors via onDataLoadComplete handler
  • BlazeInlinePlayerDelegate → Inline player load errors via onDataLoadComplete handler
  • BlazePlayerEntryPointDelegate → Entry point load errors via onDataLoadComplete handler
// 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 .general with unexpected reason to simplify surface-level error handling.
  • 🛠 If needed, use underlyingError for deeper debugging or analytics.

Error Codes

General Errors (1000–1099)

CodeDomainReasonThrown to Global Delegate
1000generalunexpected✅ Yes

Initialization Errors (1100–1199)

These errors are delivered via theBlaze.shared.initialize() completion handler.

CodeDomainReasonThrown to Global Delegate
1100initializationinvalidApiKey❌ No
1102initializationalreadyInitialized❌ No
1103initializationinitializationRequired❌ No
1104initializationinvalidGeoCode❌ No
1105initializationsdkInitializationFailed❌ No
1106initializationfetchingAppConfigFailed❌ No
1107initializationunexpected❌ No

Content Preparation Errors (1200–1299)

These errors are delivered viaprepareStories/prepareMoments/prepareVideos() completion handlers.

CodeDomainReasonThrown to Global Delegate
1200contentPreparationnoResultsForDataSourceType❌ No
1201contentPreparationinvalidDataSourceType❌ No

Widget Errors (1300–1399)

These errors are delivered via widget completion handlers and delegates.

CodeDomainReasonThrown to Global Delegate
1300widgetinvalidDataSourceType❌ No
1302widgetsdkInitializationError❌ No
1303widgetfailedUpdatingLike❌ No
1305widgetunexpected❌ No

Entry Point Errors (1400–1499)

These errors are delivered viaplayStories/playMoments/playVideos() completion handlers.

CodeDomainReasonThrown to Global Delegate
1400entryPointnoResultsForDataSourceType❌ No
1401entryPointinvalidDataSourceType❌ No
1403entryPointfailedToUpdateLike❌ No
1404entryPointunexpected❌ No

User Management Errors (1500–1599)

These errors are delivered viasetExternalUserId() completion handlers.

CodeDomainReasonThrown to Global Delegate
1500userManagementsettingExternalIdFailed❌ No
1501userManagementinvalidApiKey❌ No
1506userManagementunexpected❌ No

Universal Link Errors (1600–1699)

These errors are delivered viahandleUniversalLink() completion handlers.

CodeDomainReasonThrown to Global Delegate
1600universalLinkinvalidURL❌ No

Notification Extra Info Errors (1700–1799)

These errors are delivered via notification handling completion handlers.

CodeDomainReasonThrown to Global Delegate
1700notificationExtraInfoinvalidExtraInfoScheme❌ No

Data Source Errors (1900–1999)

These errors occur during internal data source operations.

CodeDomainReasonThrown to Global Delegate
1900generalinvalidDataSourceTypeProvided❌ No

Content Errors (2000–2099)

These errors occur during internal content operations.

CodeDomainReasonThrown to Global Delegate
2000generalfetchingContentFailed❌ No
2001generalcontentIsGeoRestricted❌ No

Asset Errors (2100–2199)

These errors occur during asset loading operations.

CodeDomainReasonThrown to Global Delegate
2100generalassetExpired✅ Yes
2101generalvideoAssetLoadingFailed✅ Yes

Storage Errors (2200–2299)

These errors occur during internal storage operations.

CodeDomainReasonThrown to Global Delegate
2200generalfailedToSaveData❌ No

Playback Errors (2400–2499)

These errors occur during media playback operations.

CodeDomainReasonThrown to Global Delegate
2400generalvideoPlaybackFailed✅ Yes
2401generalimagePlaybackFailed✅ Yes
2402generalconnectivityIssue✅ Yes

Image Loading Errors (2500–2599)

These errors occur during image loading operations.

CodeDomainReasonThrown to Global Delegate
2500generalthumbnailLoadingFailed✅ Yes
2501generalplaceholderLoadingFailed✅ Yes

Sharing Errors (2600–2699)

These errors occur during content sharing operations.

CodeDomainReasonThrown to Global Delegate
2600generalsharingFailed✅ Yes
2601generalshareConfigurationMissing✅ Yes

Direct Media Errors (2700–2799)

These errors are delivered via play method completion handlers when feature is active.

CodeDomainReasonThrown to Global Delegate
2700generaldirectMediaSourceIsInvalidForRequest✅ Yes
2701generaldirectMediaSourceIsInvalidForStories✅ Yes
2702generaldirectMediaSourceIsInvalidForMoments✅ Yes

Playback Configuration Errors (2800–2899)

These errors occur during playback configuration operations.

CodeDomainReasonThrown to Global Delegate
2800generalinvalidLoopAndAdvanceConfiguration✅ Yes

Did this page help you?