The controller now has a function CreatedAtRoute()for 201, HttpBadRequest()for 400, etc. I do not see one for 500, which I think will be HttpInternalServerError().
There is, however, a class HttpStatusCodeResultthat I can create and return:
[HttpPost]
public IActionResult Post([FromBody]string something)
{
...
try{
}
catch(Exception e)
{
return new HttpStatusCodeResult((int)HttpStatusCode.InternalServerError);
}
}
But I want to return some information from e. This may be bad practice for life, but when we test, we would like to see errors from the returned body of the API call.
HttpStatusCodeResultdoes not have a type property objector anything for the purpose of providing metadata.
What to do? I do not want to return 400 because this is not what the Internal Server Error means.