Hi, having a look at https://github.com/ServiceStack/ServiceStack/wiki/Error-Handling
I was lloking at the implementation of DtoUtils.CreateErrorResponse(request, exception);
and then the implementation DtoUtils.ToResponseStatus(ex) (that CreateErrorResponse uses).
public static ResponseStatus ToResponseStatus(this Exception exception)
{
IResponseStatusConvertible statusConvertible = exception as IResponseStatusConvertible;
if (statusConvertible == null)
return DtoUtils.CreateResponseStatus(exception.GetType().Name, exception.Message);
return statusConvertible.ToResponseStatus();
}
I think it’s not correct to just drop ex.Message … the concatenation of all messages of the innerexception chain should be provided (if any)
something like
return DtoUtils.CreateResponseStatus(exception.GetType().Name, exception.AllMessage());
where AlMesasges is the extension method below
public static string AllMessages(this Exception ex)
{
var sb = new StringBuilder();
while (ex != null)
{
sb.Append(ex.Message);
if(ex.InnerException!=null)
sb.Append(" --> ");
ex = ex.InnerException;
}
return sb.ToString();
}
personally in my custom implementation I’d just drop an ex.ToString() which returns a nice string with the messagge exception chain and the stack trace