How can I return HttpError
(own, pretty formatted, error message for front-end) then I use handy IHttpActionResult
?
public IHttpActionResult Delete(Guid id)
{
HttpError error = null;
// code omitted
if (error != null) {
// How can I achieve that?
return BadRequest(error);
}
return Ok();
}
You can use ResponseMessageResult:
public IHttpActionResult Error()
{
var error = new HttpError();
return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, error));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With