Search Unity

How do I catch an exception caused by Addressables.LoadContentCatalogAsync?

Discussion in 'Addressables' started by CanisLupus, Apr 21, 2020.

  1. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    If we call Addressables.LoadContentCatalogAsync and the path does not exist, we get 4 exceptions that begin with this one:
    Is there any way to catch these exceptions (and also avoid the errors being printed to the console)?
     
  2. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Your code does this inside DelegateList<T>.Invoke:

    upload_2020-4-22_9-19-44.png

    But this has the double consequence of 1. always having errors in the console that will distract us from actual errors, and 2. not letting us know that errors occured while getting a catalog, unless by registering Application.logMessageReceived or something like that.

    Is there a way around this? I feel that I'm missing something!
     
  3. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    You can disable error logs in the top level addressable settings, then you can access an operation's error from the handle passed into the Complete callback. Or the error will be thrown if you await the handle's Task.
     
    ZAUBAR and phobos2077 like this.
  4. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    So I was missing something after all (actually, multiple things). Thanks so much! :)