Adjust DB operation error codes for better classification
@imeyer said:
all of this looks good!
one thing i think we may want to do is not return 5xx for DB operation issues.. the 4xx class maps reasonably well..
in this case we would return a 409 because it's conflict on an entity.. and if you think about the model of the app server talking to the database, the server is the client, thus when talking SQL to it it'd be like this:
400 -> malformed query 422 ->
CHECK()failures (unique constraints, other custom constraints) 404 -> entity doesn't existit would be useful to make connection issues into 5xx class
500 or 503 for db connection issues (not including timeouts) 504 for timeouts
this way, we will still alert on valuable db issues.. but we can have softer alerts on rates of 4xx classes (labels then drive more urgency depending on the value)