3
votes

I am using ServiceStack and am having trouble getting the auto injected ResponseStatus property to work on my response DTOs. My response DTO implements IHasResponseStatus but it is not set on successful responses or during errors.

I want to use ServiceStack's built in error handling by simply being able to throw exceptions and have ServiceStack serialize the exception and stack trace for the client. I have followed the instructions on the "Validation and Error Handling" page in the wiki, but I must be missing something. Does this feature depend on a particular naming convention for the DTOs? My request DTO is names like "MyRequest" and the response is "MyRequestResponse".

1

1 Answers

4
votes

The Response DTO needs to be in the same namespace as the Request DTO and needs to be named:

RequestDto{Response}

E.g. if the request DTO of your service is Hello the response DTO should be HelloResponse

Also to enable StackTraces to also be injected in the

SetConfig(new EndpointHostConfig {
    DebugMode = true, //Enable StackTraces in development
});

More information about ServiceStack error handling can be found in the Validation wiki page.