docs.unity3d.com
    Show / Hide Table of Contents

    Property ExceptionHandler

    ExceptionHandler

    Global exception handler. This will be called whenever an IAsyncOperation.OperationException is set to a non-null value.

    Declaration
    public static Action<AsyncOperationHandle, Exception> ExceptionHandler { get; set; }
    Property Value
    Type Description
    Action<AsyncOperationHandle, Exception>
    Examples
        using System;
    using UnityEngine;
    using UnityEngine.AddressableAssets;
    using UnityEngine.ResourceManagement;
    using UnityEngine.ResourceManagement.AsyncOperations;
    
    internal class AddExceptionHandler : MonoBehaviour
    {
        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);
        }
    }
    In This Article
    • ExceptionHandler
    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