Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Error handling is inconsistent and undocumented. #165
We do not document our error handling (possible status codes and messages). In addition our current implementation is inconsistent, e.g. an error on the @login endpoint encapsulates the error type/message within an error attribute:
while an unauthorized request on a private document returns a top-level type/message json structure:
Do we want to provide a error format suggestion in plone.rest? And if so, should it be different to the common format in plone.restapi?
When implementing it we should keep in mind that plone.restapi still announces providing non JSON responses later.
Beside documenting it and unifying our code we should:
provide an utility function
provide HTTP Exceptions:
from plone.rest.exceptions import HTTPError if FAILED: raise HTTPError('Bad Request', 'missing or invalid Content-Type header')
The signature should look something like
class HTTPError(type, message, extras=None, status=400):
We might want to look into hydra error responses: https://www.hydra-cg.com/spec/latest/core/#description-of-http-status-codes-and-errors
RFC 7807 might be a good option:
We will discuss this at the Beethoven Sprint.