HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityOptimizely GitHubOptimizely NuGetLog In

Customize error handler

This topic describes how to create your own error handler logic.

To standardize error reporting across your production environment, you can provide your own custom error handler logic in the Optimizely Android SDK.

This error handler is called when an unknown feature flag key is referenced.

See the code example below. If the error handler is not overridden, a no-op error handler is used by default.

// Error handler that raises exceptions
val errorHandler: ErrorHandler = RaiseExceptionErrorHandler()

val optimizelyManager = OptimizelyManager.builder()
         .withSDKKey("<Your_SDK_Key>")
         .withErrorHandler(errorHandler)
         .withDatafileDownloadInterval(15, TimeUnit.MINUTES)
         .build(context)
// Error handler that raises exceptions
ErrorHandler errorHandler = new RaiseExceptionErrorHandler();

OptimizelyManager optimizelyManager = OptimizelyManager.builder()
        .withSDKKey("<Your_SDK_Key>")
        .withErrorHandler(errorHandler)
        .withDatafileDownloadInterval(15, TimeUnit.MINUTES)
        .build(context);