I was still looking for an example, and here is for those who still need it:
from falcon.http_error import HTTPError class MyHTTPError(HTTPError): """Represents a generic HTTP error. """ def __init__(self, status, error): super(MyHTTPError, self).__init__(status) self.status = status self.error = error def to_dict(self, obj_type=dict): """Returns a basic dictionary representing the error. """ super(MyHTTPError, self).to_dict(obj_type) obj = self.error return obj
via:
error = {"error": [{"message": "Auth token required", "code": "INVALID_HEADER"}]} raise MyHTTPError(falcon.HTTP_400, error)
source share