Package PyFoam :: Module Error
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Error

 1  #  ICE Revision: $Id: Error.py 9163 2008-08-04 08:01:10Z bgschaid $  
 2  """Standardized Error Messages""" 
 3   
 4  import traceback 
 5  import sys 
 6   
7 -def getLine(up=0):
8 try: # just get a few frames 9 f = traceback.extract_stack(limit=up+2) 10 if f: 11 return f[0] 12 except: 13 if __debug__: 14 traceback.print_exc() 15 pass 16 return ('', 0, '', None)
17
18 -def __common(standard,*text):
19 """Common function for errors and Warnings""" 20 info=getLine(up=2) 21 print >>sys.stderr, "PyFoam",standard.upper(),"on line",info[1],"of file",info[0],":", 22 for t in text: 23 print >>sys.stderr,t, 24 print >>sys.stderr
25
26 -def warning(*text):
27 """Prints a warning message with the occuring line number 28 @param text: The error message""" 29 __common("Warning",*text)
30
31 -def error(*text):
32 """Prints an error message with the occuring line number and aborts 33 @param text: The error message""" 34 __common("Fatal Error",*text) 35 sys.exit(-1)
36
37 -def debug(*text):
38 """Prints a debug message with the occuring line number 39 @param text: The error message""" 40 __common("Debug",*text)
41
42 -class PyFoamException(Exception):
43 """The simplest exception for PyFoam""" 44
45 - def __init__(self,descr):
46 self.descr=descr
47
48 - def __str__(self):
49 return "Problem in PyFoam: '"+self.descr+"'"
50