-
-
Notifications
You must be signed in to change notification settings - Fork 140
Closed
Description
The default error response contains three fields: detail, message, and status_code. The user can add more fields or remove existing ones by register a custom error processor with @app.error_processor. However, the abort and HTTPError only accept fixed arguments for the existing three fields.
We could collect additional keyword arguments in abort and HTTPError, store them as HTTPError.addtional_fields, and return them in error response when present.
Final implementation: Added a new keyword argument extra_data to collect the additional error information. See the linked PR for more details.
@app.get('/')
def missing():
abort(404, message='nothing', extra_data={'code': '123', 'status': 'not_found'})Reactions are currently unavailable