UncaughtExceptionWatcher
The UncaughtExceptionWatcher
monitors uncaught exceptions in the command/function.
It can be created using the capsula.UncaughtExceptionWatcher.__init__
method.
capsula.UncaughtExceptionWatcher.__init__
PARAMETER | DESCRIPTION |
---|---|
name |
Name of the exception. Used as a key in the output.
TYPE:
|
base |
Base exception class to catch.
TYPE:
|
Source code in capsula/_watcher/_exception.py
Configuration example
Via capsula.toml
Via @capsula.watcher
decorator
import capsula
@capsula.run()
@capsula.watcher(capsula.UncaughtExceptionWatcher("exception"))
def func(): ...
Output example
The following is an example of the output of the UncaughtExceptionWatcher
, reported by the JsonDumpReporter
:
If an exception is caught, the following is an example of the output:
"exception": {
"exception": {
"exc_type": "ZeroDivisionError",
"exc_value": "float division by zero",
"traceback": " File \"/home/nomura/ghq/github.com/shunichironomura/capsula/capsula/_run.py\", line 288, in __call__\n result = self._func(*args, **kwargs)\n File \"examples/simple_decorator.py\", line 21, in calculate_pi\n x = 10.0 / 0.0\n"
}
}