Skip to main content

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, default False.

    • 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


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.4.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

error_catcher-0.4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file error_catcher-0.4.tar.gz.

File metadata

  • Download URL: error_catcher-0.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for error_catcher-0.4.tar.gz
Algorithm Hash digest
SHA256 e6e7ab528980381044b698b33b12c91f5801d27073e4086725343e966b17f0f7
MD5 81a5353eb4d54a49569f8bb527b4ae8a
BLAKE2b-256 f4b793a494b07bb2c4a1c55dae1ee6c2bdd38b84324932af9493ead8181291e4

See more details on using hashes here.

File details

Details for the file error_catcher-0.4-py3-none-any.whl.

File metadata

  • Download URL: error_catcher-0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for error_catcher-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 40c7cbd9a5cda057fd174f759578a5be9dad8afd835a94dfca1891265c0c2ff7
MD5 43855d62ae41b2c7dc085d013d607c53
BLAKE2b-256 490909963a3f6176dd445672172ff079800cda241ec43df92dc59e49caa2559a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page