diff options
| author | Frederick Muriuki Muriithi | 2026-05-08 11:45:05 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-05-08 11:45:05 -0500 |
| commit | c82e37fd38f9589ef3853f54d40f1f4a6e935d9d (patch) | |
| tree | 748ee6fd98c857b065cf0eadef2355141b8837a3 /gn_libs | |
| parent | 78c54eed593e1ddd6fb31745e101b4d9a1d2647d (diff) | |
| download | gn-libs-c82e37fd38f9589ef3853f54d40f1f4a6e935d9d.tar.gz | |
Raise exceptions for 400, and 500 responses.
Diffstat (limited to 'gn_libs')
| -rw-r--r-- | gn_libs/monadic_requests.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gn_libs/monadic_requests.py b/gn_libs/monadic_requests.py index a09acc5..1db1aa0 100644 --- a/gn_libs/monadic_requests.py +++ b/gn_libs/monadic_requests.py @@ -26,6 +26,7 @@ def get(url, params=None, **kwargs) -> Either: try: resp = requests.get(url, params=params, timeout=timeout, **kwargs) + resp.raise_for_status() if resp.status_code in SUCCESS_CODES: return Right(resp.json()) return Left(resp) @@ -48,6 +49,7 @@ def post(url, data=None, json=None, **kwargs) -> Either: try: resp = requests.post(url, data=data, json=json, timeout=timeout, **kwargs) + resp.raise_for_status() if resp.status_code in SUCCESS_CODES: return Right(resp.json()) return Left(resp) |
