Created
January 22, 2024 15:11
-
-
Save tschreiner/dd9f290ebc8fc65f96dffc1d84fa59e7 to your computer and use it in GitHub Desktop.
Revisions
-
tschreiner created this gist
Jan 22, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import traceback import smtplib from email.mime.text import MIMEText def send_error_to_developer(error_details): msg = MIMEText(error_details) msg['Subject'] = 'Application Error Report' msg['From'] = '[email protected]' msg['To'] = '[email protected]' # Send the message via SMTP server s = smtplib.SMTP('localhost') s.send_message(msg) s.quit() def global_exception_handler(exctype, value, tb): error_details = ''.join(traceback.format_exception(exctype, value, tb)) send_error_to_developer(error_details) # Optionally, inform the user that an error occurred import sys sys.excepthook = global_exception_handler # Your application code here