docs.unity3d.com
    Show / Hide Table of Contents

    ResourceManager.ExceptionHandler

    API

    • static Action<AsyncOperationHandle, Exception> ExceptionHandler

    Description

    The ResourceManager.ExceptionHandler allows you to create and set custom exception handlers for the Addressables runtime. If no ExceptionHandler is provided, a default implementation is used.

    Exceptions created during runtime error scenarios do not get automatically thrown. They are sent to the ExceptionHandler and reported in the AsyncOperationHandle.OperationException of any given operation.

    Code Sample

    void Start()
    {
        ResourceManager.ExceptionHandler = CustomExceptionHandler;
    
        //...
    }
    
    //Gets called for every error scenario encountered during an operation.
    //A common use case for this is having InvalidKeyExceptions fail silently when a location is missing for a given key.
    void CustomExceptionHandler(AsyncOperationHandle handle, Exception exception)
    {
        if (exception.GetType() != typeof(InvalidKeyException))
                Addressables.LogException(handle, exception);
    }
    
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023