Give Page Feedback | API

Addressable System - Custom Exception Handler

This class can be used to provide the Addressable Chunk Streamer you are using with a custom method for exception handling. If you do not provide this class, and Log Runtime Exceptions is enabled in your Addressable Settings, the streamers will only log Invalid Key Exceptions. Usually you will not need to provide a custom exception handler, however the option is there if you want it.

Creating An Addressable Exception Handler

In order to add an exception handler, you will need to create a new MonoBehaviour script that derives from the AddressableExceptionHandler class. You will need to add a using DeepSpaceLabs.SAM statement to access this class.

Do note that this class is only available when an Addressables Package is present in your Project.

Once you set your custom Exception Handler to inherit from AddressableExceptionHandler, you will see a red error line on your custom class name. Right click the class name and choose Show potential fixes -> Implement abstract class. This will automatically add the HandleException method and other using statements needed by the method.

Understanding the Exception Handler

The Addressable system does not automatically throw exceptions when a non download related error occurs. Instead, the exception is passed to an Exception Handling method which can decide whether the exception should be thrown or fail silently (or whatever else you wish to do with it).The AddressableExceptionHandler class is designed to allow you to define the method that handles exceptions.

If you do not create and assign a Handler to your Chunk Streamer, the default behavior is to detect InvalidKeyExceptions and Log them via the console. No other exceptions are logged an absolutely 0 exceptions are thrown.

Note, however, that this does not apply to exceptions that are thrown by the Chunk Streamer classes themselves; it only applies to exceptions generated by the Unity Addressable System.

Using the Exception Handler

Once you have created a custom Exception Handler and added it to a game object, you can assign it to the Addressable Chunk Streamer via the Exception Handler field in the inspector.