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

Source Code for Module PyFoam.Error

 1  """Standardized Error Messages""" 
 2   
 3  import traceback 
 4  import sys 
 5   
6 -def getLine(up=0):
7 try: # just get a few frames 8 f = traceback.extract_stack(limit=up+2) 9 if f: 10 return f[0] 11 except: 12 if __debug__: 13 traceback.print_exc() 14 pass 15 return ('', 0, '', None)
16
17 -def __common(standard,*text):
18 """Common function for errors and Warnings""" 19 info=getLine(up=2) 20 print >>sys.stderr, "PyFoam",standard.upper(),"on line",info[1],"of file",info[0],":", 21 for t in text: 22 print >>sys.stderr,t, 23 print >>sys.stderr
24
25 -def warning(*text):
26 """Prints a warning message with the occuring line number an aborts 27 @param text: The error message""" 28 __common("Warning",text)
29
30 -def error(*text):
31 """Prints an error message with the occuring line number an aborts 32 @param text: The error message""" 33 __common("Fatal Error",*text) 34 sys.exit(-1)
35