Open JasonTaylorAcronym opened 2 days ago
This PR would help https://github.com/myob-oss/AccountRight_Live_API_.Net_SDK/pull/276
@JasonTaylorAcronym I may have an answer for this one. If you catch the exception type ApiCommunicationException
here it has an Errors
property that gets populated with that data from the request.
Make sure you null check the Errors property first 😉
But yes, my PR will also help a bit with this because it will allow you to better handle these errors yourself.
@dkarzon Thanks for that, it does indeed work
try
{
myobInvoice = _myobService.InsertInvoice(myobInvoice);
}
catch (ApiCommunicationException ex)
{
if (ex.Errors?.Any() == true)
{
throw new Exception(ex.Errors.First().Message, ex);
}
throw ex;
}
Currently the only message we get in the thrown exception is
But I can see in the response body what the actual issue is
Would be much more helpful to the end user if we could display the actual error messages
I tired accessing the response stream but its been disposed already