Files
Learn-Python-Programming-Th…/ch03/errorsalert.py
T
adii1823 8b802c5c62 ch03
2021-10-28 17:34:45 +05:30

19 lines
689 B
Python

# The send_email function is defined here to enable you to play with
# code, but of course it doesn't send an actual email.
def send_email(*a):
print (*a)
alert_system = 'console' # other value can be 'email'
error_severity = 'critical' # other values: 'medium' or 'low'
error_message = 'OMG! Something terrible happened!'
if alert_system == 'console':
print(error_message) #1
elif alert_system == 'email':
if error_severity == 'critical':
send_email('admin@example.com', error_message) #2
elif error_severity == 'medium':
send_email('support.1@example.com', error_message) #3
else:
send_email('support.2@example.com', error_message) #4