-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support custom 422 msg by raising ValidationError * fix grammar * clean rs err handling logic * minor naming change Co-authored-by: zclzc <[email protected]>
- Loading branch information
Showing
12 changed files
with
127 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
""" | ||
Suppose the input dataflow of our model server is as follows: | ||
**bytes** --- *deserialize*<sup>(decoding)</sup> ---> **data** | ||
--- *parse*<sup>(validation)</sup> ---> **valid data** | ||
If the raw bytes cannot be successfully deserialized, the `DecodingError` | ||
is raised; if the decoded data cannot pass the validation check (usually | ||
implemented by users), the `ValidationError` should be raised. | ||
""" | ||
|
||
|
||
class DecodingError(Exception): | ||
""" | ||
The `DecodingError` should be raised in user-implemented codes | ||
when the de-serialization for the request bytes fails. This error | ||
will set the status code to | ||
[HTTP 400]("https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400) | ||
in the response. | ||
""" | ||
|
||
|
||
class ValidationError(Exception): | ||
""" | ||
The `ValidationError` should be raised in user-implemented codes, | ||
where the validation for the input data fails. Usually it can be put | ||
after the data deserialization, which converts the raw bytes into | ||
structured data. | ||
where the validation for the input data fails. Usually, it should be | ||
put after the data de-serialization, which converts the raw bytes | ||
into structured data. This error will set the status code to | ||
[HTTP 422](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422) | ||
in the response. | ||
""" |
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.