__file__ = 'ky_error.py' __usage__ = '''error( caller, exception, [state], [debug] ) caller - eg LexicalScanner, Parser, etc. exception - eg ValueError, SyntaxError, etc. state - state related information for logging debug - any further information''' __description__ = '''Ky error handling routines. Provides a unified interface for raising exceptions during lexing, parsing and code generation.''' __author__ = 'Timothy Wakeham (timmeh)' __contact__ = 'timmeh@hiddenworlds.org' __updated__ = '28-03-2008 @ 20:18:19' __todo__ = '''Implement logging of errors. Expand the error handler to use the information it's given.''' #start import logging def Error(caller, exception, state, debug=None): print '--Error-------------------------------' + '-' * len(caller.ID) print '%s encountered an error during execution' % caller.ID print 'State conditions: %s' % state print 'Debug info: %s' % debug raise exception, 'See above'