|
@@ -8,6 +8,7 @@ using MYOB.AccountRight.SDK.Services.GeneralLedger;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Reflection;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using MYOBBaseEntity = MYOB.AccountRight.SDK.Contracts.Version2.BaseEntity;
|
|
@@ -153,7 +154,7 @@ public static class MYOBPosterUtils
|
|
|
|
|
|
public static string FormatApiException(ApiCommunicationException e)
|
|
|
{
|
|
|
- if(e.Errors.Count > 0)
|
|
|
+ if(e.Errors is not null && e.Errors.Count > 0)
|
|
|
{
|
|
|
var message = string.Join('\n', e.Errors.Select(x =>
|
|
|
{
|
|
@@ -219,6 +220,17 @@ public static class MYOBPosterUtils
|
|
|
throw new PostCancelledException();
|
|
|
}
|
|
|
}
|
|
|
+ catch(TargetInvocationException e)
|
|
|
+ {
|
|
|
+ if(e.InnerException is not null)
|
|
|
+ {
|
|
|
+ return Result.Error(e.InnerException);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Result.Error<Exception>(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
catch(Exception e)
|
|
|
{
|
|
|
return Result.Error(e);
|