add appropriate HTTP response codes for bad requests and internal errors