From 255b4607b4a975073dc4902f7cf02a10648f2e0a Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Fri, 10 May 2024 18:58:01 +0300 Subject: [PATCH] chore(isolate): inherit exceptions from IsolateException (#128) --- src/isolate/backends/_base.py | 3 ++- src/isolate/connections/common.py | 4 +++- src/isolate/connections/grpc/_base.py | 3 ++- src/isolate/connections/grpc/agent.py | 3 ++- src/isolate/exceptions.py | 2 ++ 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 src/isolate/exceptions.py diff --git a/src/isolate/backends/_base.py b/src/isolate/backends/_base.py index d907e00..1b86bf4 100644 --- a/src/isolate/backends/_base.py +++ b/src/isolate/backends/_base.py @@ -12,6 +12,7 @@ ) from isolate.backends.settings import DEFAULT_SETTINGS, IsolateSettings +from isolate.exceptions import IsolateException from isolate.logs import Log, LogLevel, LogSource __all__ = [ @@ -27,7 +28,7 @@ BasicCallable = Callable[[], CallResultType] -class EnvironmentCreationError(Exception): +class EnvironmentCreationError(IsolateException): """Raised when the environment cannot be created.""" diff --git a/src/isolate/connections/common.py b/src/isolate/connections/common.py index d227a6d..3d472f6 100644 --- a/src/isolate/connections/common.py +++ b/src/isolate/connections/common.py @@ -8,6 +8,8 @@ from tblib import Traceback, TracebackParseError +from isolate.exceptions import IsolateException + if TYPE_CHECKING: from typing import Protocol @@ -21,7 +23,7 @@ def dumps(self, obj: Any) -> bytes: ... @dataclass -class SerializationError(Exception): +class SerializationError(IsolateException): """An error that happened during the serialization process.""" message: str diff --git a/src/isolate/connections/grpc/_base.py b/src/isolate/connections/grpc/_base.py index 71d2f8a..c5c44cc 100644 --- a/src/isolate/connections/grpc/_base.py +++ b/src/isolate/connections/grpc/_base.py @@ -16,10 +16,11 @@ from isolate.connections.grpc import agent, definitions from isolate.connections.grpc.configuration import get_default_options from isolate.connections.grpc.interface import from_grpc +from isolate.exceptions import IsolateException from isolate.logs import LogLevel, LogSource -class AgentError(Exception): +class AgentError(IsolateException): """An internal problem caused by (most probably) the agent.""" diff --git a/src/isolate/connections/grpc/agent.py b/src/isolate/connections/grpc/agent.py index 5b62592..77b59de 100644 --- a/src/isolate/connections/grpc/agent.py +++ b/src/isolate/connections/grpc/agent.py @@ -22,11 +22,12 @@ from isolate.connections.grpc import definitions from isolate.connections.grpc.configuration import get_default_options from isolate.connections.grpc.interface import from_grpc, to_grpc +from isolate.exceptions import IsolateException from isolate.logs import Log, LogLevel, LogSource @dataclass -class AbortException(Exception): +class AbortException(IsolateException): message: str diff --git a/src/isolate/exceptions.py b/src/isolate/exceptions.py new file mode 100644 index 0000000..d2c4391 --- /dev/null +++ b/src/isolate/exceptions.py @@ -0,0 +1,2 @@ +class IsolateException(Exception): + pass