Skip to content

Commit cf0953b

Browse files
Coesmetic changes to avoid nesting exceptions
1 parent b948dd6 commit cf0953b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

nocodb/infra/requests_client.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ def __init__(self, auth_token: AuthToken, base_uri: str):
2121
self.__session.headers.update({"Content-Type": "application/json"})
2222
self.__api_info = NocoDBAPI(base_uri)
2323

24-
def _request(self, method, url, *args, **kwargs):
24+
def _request(self, method: str, url: str, *args, **kwargs):
2525
response = self.__session.request(method, url, *args, **kwargs)
2626
try:
2727
response.raise_for_status()
28-
except requests.exceptions.HTTPError as http_error:
28+
response_json = response.json()
29+
except requests.exceptions.JSONDecodeError:
2930
response_json = None
30-
try:
31-
response_json = response.json()
32-
except requests.exceptions.JSONDecodeError:
33-
...
31+
except requests.exceptions.HTTPError as http_error:
3432
raise NocoDBAPIError(
3533
message=str(http_error),
3634
status_code=http_error.response.status_code,

0 commit comments

Comments
 (0)