File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 3333from ..dependencies .invocation import (
3434 CancelHook ,
3535 InvocationCancelledError ,
36+ InvocationError ,
3637 invocation_logger ,
3738)
3839from ..outputs .blob import BlobIOContextDep , blobdata_to_url_ctx
@@ -280,10 +281,16 @@ def run(self) -> None:
280281 self ._status = InvocationStatus .COMPLETED
281282 self .action .emit_changed_event (self .thing , self ._status )
282283 except InvocationCancelledError :
283- logger .error (f"Invocation { self .id } was cancelled." )
284+ logger .info (f"Invocation { self .id } was cancelled." )
284285 with self ._status_lock :
285286 self ._status = InvocationStatus .CANCELLED
286287 self .action .emit_changed_event (self .thing , self ._status )
288+ except InvocationError as e :
289+ logger .error (e )
290+ with self ._status_lock :
291+ self ._status = InvocationStatus .ERROR
292+ self ._exception = e
293+ self .action .emit_changed_event (self .thing , self ._status )
287294 except Exception as e : # skipcq: PYL-W0703
288295 logger .exception (e )
289296 with self ._status_lock :
Original file line number Diff line number Diff line change @@ -117,6 +117,20 @@ class InvocationCancelledError(BaseException):
117117 """
118118
119119
120+ class InvocationError (RuntimeError ):
121+ """The invocation ended in an anticipated error state.
122+
123+ When this error is raised, action execution stops as expected. The exception will be
124+ logged at error level without a traceback, and the invocation will return with
125+ error status.
126+
127+ Unlike other types of unhandled error in a LabThings action this will not cause
128+ ASGI traceback. The ASGI traceback provides useful debug information to be logged
129+ for developers. However, for simple errors with known causes this is information
130+ overload for an average user.
131+ """
132+
133+
120134class CancelEvent (threading .Event ):
121135 """An Event subclass that enables cancellation of actions.
122136
Original file line number Diff line number Diff line change 11"""A submodule for custom LabThings-FastAPI Exceptions."""
22
3- from .dependencies .invocation import InvocationCancelledError
3+ from .dependencies .invocation import InvocationCancelledError , InvocationError
44
55
66class NotConnectedToServerError (RuntimeError ):
@@ -13,4 +13,4 @@ class NotConnectedToServerError(RuntimeError):
1313 """
1414
1515
16- __all__ = ["NotConnectedToServerError" , "InvocationCancelledError" ]
16+ __all__ = ["NotConnectedToServerError" , "InvocationCancelledError" , "InvocationError" ]
You can’t perform that action at this time.
0 commit comments