Skip to content

Commit 1bad8f9

Browse files
authored
Merge pull request #512 from jaswilli/handle_error-doc
Update docs to reflect current handle_error argument names
2 parents deaa8e5 + 8dfa74d commit 1bad8f9

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ Contributors (chronological)
5050
* Tim Gates `@timgates42 <https://github.com/timgates42>`_
5151
* Lefteris Karapetsas `@lefterisjp <https://github.com/lefterisjp>`_
5252
* Utku Gultopu `@ugultopu <https://github.com/ugultopu>`_
53+
* Jason Williams `@jaswilli <https://github.com/jaswilli>`_

docs/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Then decorate that function with :func:`Parser.error_handler <webargs.core.Parse
196196
197197
198198
@parser.error_handler
199-
def handle_error(error, req, schema, *, status_code, headers):
199+
def handle_error(error, req, schema, *, error_status_code, error_headers):
200200
raise CustomError(error.messages)
201201
202202
Parsing Lists in Query Strings

docs/upgrading.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,27 @@ prepared to traverse messages by one additional level. For example:
308308
log.debug("bad value for '{}' [{}]: {}".format(field, location, messages))
309309
310310
311+
Custom Error Handler Argument Names Changed
312+
-------------------------------------------
313+
314+
If you define a custom error handler via `@parser.error_handler` the function
315+
arguments are now keyword-only and `status_code` and `headers` have been renamed
316+
`error_status_code` and `error_headers`.
317+
318+
.. code-block:: python
319+
320+
# webargs 5.x
321+
@parser.error_handler
322+
def custom_handle_error(error, req, schema, status_code, headers):
323+
...
324+
325+
326+
# webargs 6.x
327+
@parser.error_handler
328+
def custom_handle_error(error, req, schema, *, error_status_code, error_headers):
329+
...
330+
331+
311332
Some Functions Take Keyword-Only Arguments Now
312333
----------------------------------------------
313334

@@ -325,7 +346,7 @@ the changes.
325346
326347
327348
# webargs 6.x
328-
def handle_error(error, req, schema, *, status_code, headers):
349+
def handle_error(error, req, schema, *, error_status_code, error_headers):
329350
...
330351
331352
`parser.__init__` methods:

src/webargs/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class CustomError(Exception):
434434
435435
436436
@parser.error_handler
437-
def handle_error(error, req, schema, *, status_code, headers):
437+
def handle_error(error, req, schema, *, error_status_code, error_headers):
438438
raise CustomError(error.messages)
439439
440440
:param callable func: The error callback to register.

0 commit comments

Comments
 (0)