-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
294 additions
and
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Persistence | ||
|
||
Exceptions during the rendering of API calls are wrapped, logged and provided | ||
generic http status codes by default. | ||
|
||
Guillotina provides a mechanism for customizing the status codes and type of | ||
responses given depending on the exception type. | ||
|
||
## Custom exception response | ||
|
||
```python | ||
from aiohttp.web_exceptions import HTTPPreconditionFailed | ||
from guillotina import configure | ||
from guillotina.interfaces import IErrorResponseException | ||
|
||
import json | ||
|
||
|
||
@configure.adapter( | ||
for_=json.decoder.JSONDecodeError, | ||
provides=IErrorResponseException) | ||
def json_decode_error_response(exc, error='', eid=None): | ||
return HTTPPreconditionFailed( | ||
reason=f'JSONDecodeError: {eid}') | ||
``` |
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 |
---|---|---|
|
@@ -21,4 +21,5 @@ Contents: | |
persistence | ||
blob | ||
router | ||
exceptions | ||
api/index |
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.