I have a Web API project and right my methods always returns HttpResponseMessage.
So, if it works or fails I return:
No errors:
You can return an error response to provide more detail.
public HttpResponseMessage Get()
{
HttpError myCustomError = new HttpError("The file has no content or rows to process.") { { "CustomErrorCode", 42 } };
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, myCustomError);
}
Would return:
{
"Message": "The file has no content or rows to process.",
"CustomErrorCode": 42
}
More details here: http://blogs.msdn.com/b/youssefm/archive/2012/06/28/error-handling-in-asp-net-webapi.aspx
I also use http://en.wikipedia.org/wiki/List_of_HTTP_status_codes to help me determine what http status code to return.