ServiceGateway throws AggregateException

I thought that the Send() method of the ServiceGateway will throw a exception of type WebServiceException in case of error

Documentation:

[…] One noticeable difference is that any Exceptions thrown by downstream Services are automatically converted into the same WebServiceException that clients would throw when calling the Service externally […]

But when I try to POST a poco with validation rules and that validation fails, it throws a AggregateException instead (the WebServiceException is the only element in the InnerExceptions collection)

Is this supposed to work like that ?
Thank you

// In my controller
...
Gateway.Send(new MyPoco()); // throws AggregateException
...

// My Poco
public class MyPoco : IPost
{
   public string Prop1 { get; set; }
}

// My validator
public class MyPocoValidator : AbstractValidator<MyPoco>
{
   public MyPocoValidator()
   {
      RuleFor(x => x.Prop1).NotEmpty();
   }
}

Where are you calling the Gateway? In an MVC Controller or ServiceStack Service?

In a MVC controller (NetCore 3.1)

This should be resolved from this commit. This change is available from v5.9.3+ that’s now available on MyGet.

1 Like