Kaydet (Commit) 5558b893 authored tarafından Guido van Rossum's avatar Guido van Rossum

Improved error handling.

üst 5378d5c4
......@@ -4,11 +4,22 @@
# Extension to multiple mailboxes and other bells & whistles are left
# as exercises for the reader.
import posix
import sys, posix
# Open mailbox file. Exits with exception when this fails.
mail = open(posix.environ['MAIL'], 'r')
try:
mailbox = posix.environ['MAIL']
except RuntimeError:
sys.stderr.write \
('Please set environment variable MAIL to your mailbox\n')
sys.exit(2)
try:
mail = open(mailbox, 'r')
except RuntimeError:
sys.stderr.write('Cannot open mailbox file: ' + mailbox + '\n')
sys.exit(2)
while 1:
line = mail.readline()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment