mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 08:20:02 +02:00
improves exception deserialization
Tries to use builtins exceptions if possible.
This commit is contained in:
parent
d792601663
commit
ad2800aaf6
@ -89,7 +89,12 @@ class Deserializer:
|
||||
|
||||
@classmethod
|
||||
def deserialize_exception(cls, serialized_object: SerializedObject) -> NoReturn:
|
||||
exception = type(serialized_object["name"], (Exception,), {}) # type: ignore
|
||||
import builtins
|
||||
|
||||
try:
|
||||
exception = getattr(builtins, serialized_object["name"]) # type: ignore
|
||||
except AttributeError:
|
||||
exception = type(serialized_object["name"], (Exception,), {}) # type: ignore
|
||||
raise exception(serialized_object["value"])
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
x
Reference in New Issue
Block a user