caught an index error exception objects and lists here' the way extended this module for an exception of my ownfile oops pyfrom __future__ import print_function class myerror(exception)pass def oops()raise myerror('spam!'def doomed()tryoops(except indexerrorprint('caught an index error!'except myerror as dataprint('caught error:'myerrordataelseprint('no error caught 'if __name__ ='__main__'doomed(python oops py caught errorspamlike all class exceptionsthe instance is accessible via the as variable datathe error message shows both the class (and its instance (spam!the instance must be inheriting both an __init__ and __repr__ or __str__ from python' excep tion classor it would print much like the class does see for details on how this works in built-in exception classes error handling here' one way to solve this one (file exctools pyi did my tests in filerather than interactivelybut the results are similar enough for full credit notice that the empty except and sys exc_info approach used here will catch exitrelated exceptions that listing exception with an as variable won'tthat' probably not ideal in most applications codebut might be useful in tool like this designed to work as sort of exceptions firewall import systraceback def safe(callee*pargs**kargs)trycallee(*pargs**kargscatch everything else exceptor "except exception as :traceback print_exc(print('got % % (sys exc_info()[ ]sys exc_info()[ ])if __name__ ='__main__'import oops safe(oops oops appendix dsolutions to end-of-part exercises