With ServiceStack, it's important to implement exception handling/logging in two places:
Inside of each
ServiceRunner<T>
.public class MyServiceRunner<T> : ServiceRunner<T> { public override object HandleException(IRequestContext requestContext, T request, Exception ex) { // Implement your exception handling/logging here. // T request is your request DTO. } }
Inside of AppHost, so that you can handle unhandled exceptions occuring outside of services.
public override void Configure(Container container) { ExceptionHandler = (req, res, operationName, ex) => { //Handle Unhandled Exceptions occurring outside of Services //E.g. Exceptions during Request binding or in filters: } }
My Question:
- In #1, you have easy access to the request DTO (i.e. for logging purposes).
- Do I have access to the request DTO (or the request payload equivalent) when I'm handling exceptions occuring outside of services?