I am using the following code in my controller when I submit a new entry:
// POST /api/Content/
public HttpResponseMessage PostContent(Content content)
{
try
{
content.ModifiedDate = DateTime.Now;
_uow.Contents.Add(content);
_uow.Commit();
var response = Request.CreateResponse<Content>(HttpStatusCode.Created, content);
return response;
}
catch (DbUpdateException ex)
{
return Request.CreateErrorResponse(HttpStatusCode.Conflict, ex);
}
}
This only picks up DbUpdateExceptions so if there is another kind of exception then I think I need to handle it differently.
Can anyone suggest how I should handle other exceptions?