Debian Codegraph @

src/globus_sdk/services/gcs/errors.py

raw
1 from __future__ import annotations
2
3 import typing as t
4
5 import requests
6
7 from globus_sdk import exc
8
9
10 class GCSAPIError(exc.GlobusAPIError):
11 """
12 Error class for the GCS Manager API client
13 """
14
15 def __init__(self, r: requests.Response) -> None:
16 self.detail_data_type: str | None = None
17 self.detail: None | str | dict[str, t.Any] = None
18 super().__init__(r)
19
20 def _get_args(self) -> list[t.Any]:
21 args = super()._get_args()
22 args.append(self.detail_data_type)
23 # only add detail if it's a string (don't want to put a large object into
24 # stacktraces)
25 if isinstance(self.detail, str):
26 args.append(self.detail)
27 return args
28
29 def _post_parse_hook(self) -> bool:
30 # detail can be a full document, so fetch, then look for a DATA_TYPE
31 # and expose it as a top-level attribute for easy access
32 self.detail = self._dict_data.get("detail")
33 if isinstance(self.detail, dict) and "DATA_TYPE" in self.detail:
34 self.detail_data_type = self.detail["DATA_TYPE"]
35 return True