Skip to content

Commit

Permalink
Merge pull request #512 from jaswilli/handle_error-doc
Browse files Browse the repository at this point in the history
Update docs to reflect current handle_error argument names
  • Loading branch information
sirosen authored May 13, 2020
2 parents deaa8e5 + 8dfa74d commit 1bad8f9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ Contributors (chronological)
* Tim Gates `@timgates42 <https://github.com/timgates42>`_
* Lefteris Karapetsas `@lefterisjp <https://github.com/lefterisjp>`_
* Utku Gultopu `@ugultopu <https://github.com/ugultopu>`_
* Jason Williams `@jaswilli <https://github.com/jaswilli>`_
2 changes: 1 addition & 1 deletion docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Then decorate that function with :func:`Parser.error_handler <webargs.core.Parse
@parser.error_handler
def handle_error(error, req, schema, *, status_code, headers):
def handle_error(error, req, schema, *, error_status_code, error_headers):
raise CustomError(error.messages)
Parsing Lists in Query Strings
Expand Down
23 changes: 22 additions & 1 deletion docs/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,27 @@ prepared to traverse messages by one additional level. For example:
log.debug("bad value for '{}' [{}]: {}".format(field, location, messages))
Custom Error Handler Argument Names Changed
-------------------------------------------

If you define a custom error handler via `@parser.error_handler` the function
arguments are now keyword-only and `status_code` and `headers` have been renamed
`error_status_code` and `error_headers`.

.. code-block:: python
# webargs 5.x
@parser.error_handler
def custom_handle_error(error, req, schema, status_code, headers):
...
# webargs 6.x
@parser.error_handler
def custom_handle_error(error, req, schema, *, error_status_code, error_headers):
...
Some Functions Take Keyword-Only Arguments Now
----------------------------------------------

Expand All @@ -325,7 +346,7 @@ the changes.
# webargs 6.x
def handle_error(error, req, schema, *, status_code, headers):
def handle_error(error, req, schema, *, error_status_code, error_headers):
...
`parser.__init__` methods:
Expand Down
2 changes: 1 addition & 1 deletion src/webargs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class CustomError(Exception):
@parser.error_handler
def handle_error(error, req, schema, *, status_code, headers):
def handle_error(error, req, schema, *, error_status_code, error_headers):
raise CustomError(error.messages)
:param callable func: The error callback to register.
Expand Down

0 comments on commit 1bad8f9

Please sign in to comment.