Skip to content

Commit

Permalink
attempts to dynamic import response exception
Browse files Browse the repository at this point in the history
  • Loading branch information
David Erb committed May 10, 2023
1 parent f90b699 commit aca7ae7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/dls_servbase_api/aiohttp_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from dls_utilpack.callsign import callsign
from dls_utilpack.describe import describe
from dls_utilpack.explain import explain, explain2
from dls_utilpack.import_class import import_classname_from_modulename

# Exceptions.
from dls_servbase_api.exceptions import (
Expand Down Expand Up @@ -128,8 +129,15 @@ async def client_protocolj(self, request_object, cookies=None):
exception_message = response_dict["exception"].get(
"message", "no message"
)
exception_class = RuntimeError
exception_message = f"{qualname}: {exception_message}"
try:
modulename = ".".join(qualname.split(".")[:-1])
classname = qualname.split(".")[-1]
exception_class = import_classname_from_modulename(
classname, modulename
)
except:
exception_class = RuntimeError
exception_message = f"{qualname}: {exception_message}"
except Exception:
pass

Expand Down

0 comments on commit aca7ae7

Please sign in to comment.