Given an exception filter like this.
public override void OnException(HttpActionExecutedContext context)
{
var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
{
// what must I change here to return an object
// similar to the default exception handler?
Content = new StringContent("THIS IS MY ERROR"),
};
throw new HttpResponseException(resp);
}
The exception reason returned to the client javascript is a plain string.
When an exception is thrown in a default WebApi2
controller, the default reason object returned contains the config, data, headers etc. I can't find an example of how to return all this extra information from my exception filter. I tried checking out the source to no avail...
$http.get('/mydata')
.catch(function(reason) { ... do stuff with reason })
.then(...);
What do I need to change in order to return the same default response rather than just a plain string.
Content = new ... // what goes here.