i have a scenario where some unknown exceptions
may be raised during program execution and i can't except
most of them and i want every time any exception
will raise an email should send to me as exceptions
cause program to terminate if not properly catch!
so i have read about python
provide atexit
module but it did not work with exceptions
so my question is , is there any way to make atexit
work with exceptions
?? so every any exception raised and programs terminates it should send me a mail?
thanks
atexit is a module in python which contains two functions register() and unregister(). The main role of this module is to perform clean up upon interpreter termination. Functions that are registered are automatically executed upon interpreter termination.
Python Exceptions. When a Python program meets an error, it stops the execution of the rest of the program. An error in Python might be either an error in the syntax of an expression or a Python exception.
The try block lets you test a block of code for errors. The except block lets you handle the error. The else block lets you execute code when there is no error. The finally block lets you execute code, regardless of the result of the try- and except blocks.
Look at sys.excepthook
. As its name suggests, it's a hook into the exception. You can use it to send you an email when exceptions are raised.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With