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.
However, 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. |
-
source - the handler function that raised the error.
-
trigger - the area of functionality where the error originated. One of the following values:
-
DYNAMIC_PROPERTIES_RULE
-
CONFIGURATION_FETCHED_HANDLER
-
IMPRESSION_HANDLER
-
CUSTOM_PROPERTY_GENERATOR
-
-
error - the error that occurred in the identified source.
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 errorDetails: print('Unhandled error. trigger type: {}, source: {}, exception: {}.'.format(errorDetails.exception_trigger, errorDetails.exception_source, errorDetails.exception)))
Rox.setUserspaceUnhandledErrorHandler(new UserSpaceExceptionHandler() { @Override public void handleUserSpaceException(ExceptionTrigger source, Throwable exception) { System.out.println("Unhandled exception in " + source.name() + ": " + exception.getMessage()); } });
Rox::Server::RoxServer.use_userspace_unhandled_error_handler() { |e| puts "custom error handler: #{e}" }
Rox::setUserspaceUnhandledErrorHandler(function (UserspaceUnhandledErrorArgs $args) { echo "{$args->getExceptionSource()} threw an uncaught error {$args->getException()}"; });
[ROXCore setUserspaceUnhandledErrorHandler:^(ROXExceptionTrigger trigger, NSException * _Nonnull exception) { NSLog(@"%lu threw an uncaught error %@", trigger, exception); }];