Skip to main content

With Python's try-except statement, experience a significantly more flexible way to receive notifications.

Project description

Python: CatchException

With Python's try-except statement, experience a significantly more flexible way to receive notifications. You can receive alerts through various messaging platforms such as email, Slack, and Discord. This package offers an extensive range of notification options to suit your needs.

Python package CatchException can give a single line alarm with an error message, whereas knockknock gives a process ending alarm with decorator and cli.


Quick Start

CatchException installation

pip insall catchexception

Features

Mail

In the except statement, an email is sent along with the error message. Additionally, you can send emails from any desired line.

a. Log in with the sender's email ID.
b. Obtain an app password for sending Google Mail at the following link.

from CatchException import ExceptionMail, SuccessMail, SendMail
sys.excepthook = ExceptionMail.__call__

try:
    main() # Your Code Here
    SuccessMail().__call__()    # No Exception -> Send Success mail.
except ExceptionMail:           # Exception -> Send Fail mail.
    pass

SendMail().__call__()           # When Process Ended -> Any Line mail.
See Example...
import sys
from CatchException import ExceptionMail, SuccessMail

# 01. Set variable.
global gmail_receiver, gmail_sender, gmail_app_password_of_sender, SendMail
gmail_receiver = 'parkminwoo1991@gmail.com'
gmail_sender = 'heydudenotice@gmail.com'
gmail_app_password_of_sender = 'xxxxxxxxxxx'
sys.excepthook = ExceptionMail.__call__

try:
    # 02. Locate your code.
    print(1/0)             
    SuccessMail().__call__() # Success Mail

# Exception Mail
except ExceptionMail as e:                    
    sys.exit()
    print(e)

SendMail().__call__()     # Put Any Line: Sending mail

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

catchexception-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

catchexception-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file catchexception-0.1.0.tar.gz.

File metadata

  • Download URL: catchexception-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for catchexception-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4908895647585e5dd25d9ed3ea0c5508f2341ed04f5350349265a2ca239abb8
MD5 1b46781ead900f3ed986e1cc622cd010
BLAKE2b-256 c6a5da3d66a96b4c34b96c64d15b069cfb866819b2a52005e0013880a726da0f

See more details on using hashes here.

File details

Details for the file catchexception-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for catchexception-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d19963a9960b34c935029a4cd90aa2e50adb99f80dac39986459f98295bd98c9
MD5 2afb1972624c7337fb9ccb7859ed821e
BLAKE2b-256 cbbd89ffe6394dbefcaad68a3e39ace68ad0b73127109fa413079dbfce3c1f42

See more details on using hashes here.

Supported by

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