# L-28 MCS 260 Wed 16 Mar 2016 : readfilename3.py

"""
Prompts the user for a file name and displays
an error message if the name given by the user
does not correspond to a file.
"""

class FileNotThere(IOError):
    """
    The exception FileNotThere is raised when a
    file does not exist.  The argument of the
    exception is the file name.
    """
    def __init__(self, name=''):
        "stores the name of the file"
        IOError.__init__(self)
        self.name = name

NAME = input('Give the name of a file : ')
try:
    try:
        INFILE = open(NAME, 'r')
    except IOError:
        raise FileNotThere(NAME)
except FileNotThere as err:
    print('file \"' + err.name + '\" does not exist')
