Return "Bad Request" for errors caused by client

Currently, `enforce()` is used to check for invalid requests to the server, for example malformed HTTP queries, or missing/wrongly typed query parameters in APIs. `enforce()` throws a generic `Exception`, which makes the server return `500 Internal Server Error` to the client. However, the appropriate response for invalid requests is `400 Bad Request`.