File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 22from types import MethodType
33
44from fastcs .controllers import BaseController
5+ from fastcs .logging import bind_logger
56from fastcs .methods .method import Controller_T , Method
67
8+ logger = bind_logger (logger_name = __name__ )
9+
710UnboundCommandCallback = Callable [[Controller_T ], Coroutine [None , None , None ]]
811"""A Command callback that is unbound and must be called with a `Controller` instance"""
912CommandCallback = Callable [[], Coroutine [None , None , None ]]
@@ -28,7 +31,18 @@ def _validate(self, fn: CommandCallback) -> None:
2831 raise TypeError (f"Command method cannot have arguments: { fn } " )
2932
3033 async def __call__ (self ):
31- return await self ._fn ()
34+ return await self .fn ()
35+
36+ @property
37+ def fn (self ):
38+ async def command ():
39+ try :
40+ return await self ._fn ()
41+ except Exception :
42+ logger .exception ("Command failed" , fn = self ._fn )
43+ raise
44+
45+ return command
3246
3347
3448class UnboundCommand (Method [Controller_T ]):
You can’t perform that action at this time.
0 commit comments