mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-21 00:40:01 +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
|
@classmethod
|
||||||
def deserialize_exception(cls, serialized_object: SerializedObject) -> NoReturn:
|
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"])
|
raise exception(serialized_object["value"])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user