I’m using Graph and my c# code is having to handle some of the errors it can throw. I want to handle a specific error where the mailbox is not found.
I get this in the visual studio output:
Exception thrown: 'Microsoft.Graph.Models.ODataErrors.ODataError' in System.Private.CoreLib.dll
I tried do a catch like this but it doesnt catch it:
catch (ODataError odataError)
{
Debug.Print(string.Format("Error Code: {0}", odataError.Error.Code));
Debug.Print(string.Format("Error Message: {0}", odataError.Error.Message));
}
A Catch (Exception ex) catches it, but I want to handle this type of exception differently to anything else that might come up.
Picking up the details from the general catch I see this.
How can I set up a specific catch statement for this error?
Thanks