ServiceStack/ServiceStack — Issue #31: Exceptions incorrectly rethrown in places in source code.
Author: bluetentacle
Created: 2011-10-15 01:18:19+00:00
State: open

ServiceClientBase.HandleResponseException and ServiceBase.HandleException both rethrows the exception passed to it. This causes the original stack trace to be lost and makes it harder to track down problems.

It seems that ServiceClientBase.HandleResponseException should return null in the event that the exception cannot be handled, so that the calling method can do an implicit rethrow, preserving the stack trace:

catch (Exception ex)
{
var response = HandleResponseException(ex, Web.HttpMethod.Post, requestUri, request);

if (response == null) throw;

return response;
}

Likewise for ServiceBase.HandleException:

catch (Exception ex)
{
var value = HandleException(request, ex);

if (value == null) throw;

return value;
}

This is only feasible, of course, if the existing code does not return null under any other circumstance, which appears to be the case. What do you think?