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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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