User space error handler

It is normally recommended to wrap all handlers used on the Rox platform (setCustomProperty, impressionHandler, ConfigurationFetchedHandler, dynamicPropertyRuleHandler) with try-catch in order to be in the right context in case of an error.

Hoever, there is a fallback handler called Rox.setUserspaceUnhandledErrorHandler, which can be used for debugging, or for further error handling. An Error thrown within this handler will be written to a log, and will not bubble up.

If no setUserspaceUnhandledErrorHandler is set, the default behavior will be writing all uncaught errors to the log.

Refer to the handler parameters below for more details.

User space error handler is only avaibale on SDKs version 5 or later.

  • trigger - which handler raise the error, one of the following strings:

    • DYNAMIC_PROPERTIES_RULE

    • CONFIGURATION_FETCHED_HANDLER

    • IMPRESSION_HANDLER

    • CUSTOM_PROPERTY_GENERATOR

  • error - the error raised from the handler

React Native JavaScript Node.js .NET Python JVM, Android
Rox.setUserspaceUnhandledErrorHandler((trigger, error) => {
  console.log(`${trigger} threw an uncaught error ${error}`);
})
Rox.setUserspaceUnhandledErrorHandler((trigger, error) => {
  console.log(`${trigger} threw an uncaught error ${error}`);
})
Rox.setUserspaceUnhandledErrorHandler((trigger, error) => {
  console.log(`${trigger} threw an uncaught error ${error}`);
})
Rox.SetUserspaceUnhandledErrorHandler((unhandledErrorArgs) => {
  Console.WriteLine("unhandled error. trigger type: {0}, source {1}, exception {2}.",
    unhandledErrorArgs.exceptionTrigger,
    unhandledErrorArgs.exceptionSource.ToString(),
    unhandledErrorArgs.exception.ToString());
});
Rox.set_userspace_unhandled_error_handler(lambda trigger, error: print('{} threw an uncaught error {}'.format(trigger, error)))
Rox.setUserspaceUnhandledErrorHandler(new UserSpaceExceptionHandler() {
    @Override
    public void handleUserSpaceException(ExceptionTrigger source, Throwable exception) {
        System.out.println("Unhandled exception in " + source.name() + ": " + exception.getMessage());
    }
});