Errors¶
-
kinto.core.errors.
http_error
(httpexception, errno=None, code=None, error=None, message=None, info=None, details=None)¶ Return a JSON formated response matching the error protocol.
Parameters: - httpexception – Instance of
httpexceptions
- errno – stable application-level error number (e.g. 109)
- code – matches the HTTP status code (e.g 400)
- error – string description of error type (e.g. “Bad request”)
- message – context information (e.g. “Invalid request parameters”)
- info – information about error (e.g. URL to troubleshooting)
- details – additional structured details (conflicting record)
Returns: the formatted response object
Return type: - httpexception – Instance of
-
kinto.core.errors.
json_error_handler
(errors)¶ Cornice JSON error handler, returning consistant JSON formatted errors from schema validation errors.
This is meant to be used is custom services in your applications.
upload = Service(name="upload", path='/upload', error_handler=errors.json_error_handler)
Warning
Only the first error of the list is formatted in the response. (c.f. protocol).
-
kinto.core.errors.
raise_invalid
(request, location='body', name=None, description=None, **kwargs)¶ Helper to raise a validation error.
Parameters: - location – location in request (e.g.
'querystring'
) - name – field name
- description – detailed description of validation error
Raises: - location – location in request (e.g.
-
kinto.core.errors.
send_alert
(request, message=None, url=None, code='soft-eol')¶ Helper to add an Alert header to the response.
Parameters: - code – The type of error ‘soft-eol’, ‘hard-eol’
- message – The description message.
- url – The URL for more information, default to the documentation url.