A decorator to trace error and catch variables.
Project description
Error Catcher
Convenient and comprehensive traceback decorator for Python scripts.
To use this decorator, simply attach it to your function:
from error_catcher import silent
@silent(key_vars=[], log_file='', ascending=False)
def func():
i, j = 1, 0
return i / j
func()
Parameters
-
key_vars
: list, default[]
.- This is a list of variable names to be caught. Once an exception happens, the returned message will include the corresponding value of these variables in the most recent frame, both globally or locally.
-
log_file
: string, default''
.- If this value is set non-empty, the returned message will be passed to a log file under the same folder as the Python scripts. You are suggested to use '.log' or '.txt' format.
- By default, it is empty and the returned message will be printed directly.
-
ascending
: Bool, defaultFalse
.- This parameter decides whether to append the returned message to the end of the log file (True) or to the top of the log file (False).
- If log_file is set empty, this parameter will have no impact.
Return
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
error_catcher-0.3.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for error_catcher-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85ddafacaf0a36d4cecacf50848b748a985d11ed8d6619f76dbd320bfb392d02 |
|
MD5 | 411557aaee2faf6386032def6916f732 |
|
BLAKE2b-256 | 3f078aaa9253cfc85748ffb2ab5de26dddbc7e3f059089ef679359698e4a9fe7 |