-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate status and headers params of ValidationErrors
* `status` and `headers` kwargs are deprecated (close #336) * Add `error_status_code` and `error_headers`: See #327 (comment) ```python def validate_foo(val): # Before ... raise ValidationError("Error!", status_code=400) @use_args({"foo": fields.Str(validate=validate_foo)}) def my_view(args): ... def validate_foo(val): # After ... raise ValidationError("Error!") @use_args( {"foo": fields.Str(validate=validate_foo)}, error_status_code=400 ) def my_view(args): ... ``` * error_handler functions and handle_error methods now take error_status_code and error_headers arguments. Backwards compatibility was maintained by checking the the number of arguments in the signatures. ```python @parser.error_handler def handle_error(error, req): # Before raise CustomError(error.messages) @parser.error_handler def handle_error(error, req, status_code, headers): # After raise CustomError(error.messages) @parser.error_handler def handle_error(error, **kwargs): # Also works raise CustomError(error.messages) ```
- Loading branch information
Showing
13 changed files
with
223 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.