0

Using ASP.NET MVC 5 and the Xero.API.SDK.2.2.1.13.

I'm trying to handle all possible errors thrown when calling the Xero Api. I'm attempting this through over riding the OnException action within my BaseController. This successfully catches all errors thrown but I am unable to access the list of ValidationErrors which appears to be contained within the filterContext object (see below) when I'm debugging. I'm also unable to create a XeroApi.ValidationException object from the filterContext object.

Does anyone know how to access the ValidationErrors in this instance? Or have a more suitable way of handling all xero and other related errors within a single controller?

 protected override void OnException(ExceptionContext filterContext)
 {
    //Below line results in error: "cannot convert System.Exception to 
     ValidationException. An Explicit conversion exists".
     ValidationException ex = filterContext.Exception;

     Exception ex = filterContext.Exception;

     filterContext.ExceptionHandled = true;
 }
MJ_Wales
  • 873
  • 2
  • 8
  • 20

1 Answers1

0

Answer provided by Henzard Kruger on the Xero Community forum:

Just hack the Xero dll. You need to deal with the error in https://github.com/XeroAPI/Xero-Net/blob/master/Xero.Api/Infrastructure/Http/XeroHttpClient.cs#L105 then just recompile the DLL.

Issue was resolved after following the above advice.

MJ_Wales
  • 873
  • 2
  • 8
  • 20