Skip to content

Commit e53e014

Browse files
Add docstring to InvocationCancelledError and expose to new api via exceptions.
Also change from SystemExit error as this is not the corrcect error to inherit from.
1 parent 7957450 commit e53e014

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/labthings_fastapi/dependencies/invocation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ def invocation_logger(id: InvocationID) -> logging.Logger:
3333
InvocationLogger = Annotated[logging.Logger, Depends(invocation_logger)]
3434

3535

36-
class InvocationCancelledError(SystemExit):
37-
pass
36+
class InvocationCancelledError(BaseException):
37+
"""An invocation was cancelled by the user.
38+
39+
Note that this inherits from BaseException so won't be caught by
40+
`except Exception`, it must be handled specifically.
41+
"""
3842

3943

4044
class CancelEvent(threading.Event):

src/labthings_fastapi/exceptions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""A submodule for custom LabThings-FastAPI Exceptions"""
22

3+
from .dependencies.invocation import InvocationCancelledError
4+
35

46
class NotConnectedToServerError(RuntimeError):
57
"""The Thing is not connected to a server
@@ -9,3 +11,6 @@ class NotConnectedToServerError(RuntimeError):
911
connected to a ThingServer. A server connection is needed
1012
to manage asynchronous behaviour.
1113
"""
14+
15+
16+
__all__ = ["NotConnectedToServerError", "InvocationCancelledError"]

0 commit comments

Comments
 (0)