HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

Customize error handler

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

You can provide your own custom error handler logic to standardize across your production environment.

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);

Did this page help you?