Hands-On RESTful API Design Patterns and Best Practices
上QQ阅读APP看书,第一时间看更新

Errors representation

Error status codes of HTTP methods (4xx and 5xx) can carry client-readable information in the response body. The following rules present consistent forms of errors and error responses:

  • Errors and error responses should be consistent
  • Error types for generic and for common error conditions should also be consistent

The following diagram depicts a sample JSON response and addresses how errors and error codes predominate in API responses: