Skip to content

Commit

Permalink
add exception raising for uninitialized API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
InnocentBug committed Feb 28, 2024
1 parent 0102829 commit ea8c833
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cript/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,7 @@ def _capsule_request(self, url_path: str, method: str, api_request: bool = True,
kwargs
additional keyword arguments that are passed to `request.request`
"""

url: str = self.host
if api_request:
url += f"/{self.api_prefix}/{self.api_version}"
Expand All @@ -990,6 +991,8 @@ def _capsule_request(self, url_path: str, method: str, api_request: bool = True,
pre_log_message += "..."
self.logger.debug(pre_log_message)

if self._api_request_session is None:
raise CRIPTAPIRequiredError
response: requests.Response = self._api_request_session.request(url=url, method=method, timeout=timeout, **kwargs)
post_log_message: str = f"Request return with {response.status_code}"
if self.extra_api_log_debug_info:
Expand Down

0 comments on commit ea8c833

Please sign in to comment.