2 # $Id: ErrorCatchers.py,v 1.7 2005/01/03 19:59:07 tavis_rudd Exp $
3 """ErrorCatcher class for Cheetah Templates
6 ================================================================================
7 Author: Tavis Rudd <tavis@damnsimple.com>
8 Version: $Revision: 1.7 $
10 Last Revision Date: $Date: 2005/01/03 19:59:07 $
12 __author__
= "Tavis Rudd <tavis@damnsimple.com>"
13 __revision__
= "$Revision: 1.7 $"[11:-2]
16 from Cheetah
.NameMapper
import NotFound
18 class Error(Exception):
22 _exceptionsToCatch
= (NotFound
,)
24 def __init__(self
, templateObj
):
28 return self
._exceptionsToCatch
30 def warn(self
, exc_val
, code
, rawCode
, lineCol
):
35 class BigEcho(ErrorCatcher
):
36 def warn(self
, exc_val
, code
, rawCode
, lineCol
):
37 return "="*15 + "<" + rawCode
+ " could not be found>" + "="*15
39 class KeyError(ErrorCatcher
):
40 def warn(self
, exc_val
, code
, rawCode
, lineCol
):
41 raise KeyError("no '%s' in this Template Object's Search List" % rawCode
)
43 class ListErrors(ErrorCatcher
):
44 """Accumulate a list of errors."""
47 def __init__(self
, templateObj
):
48 ErrorCatcher
.__init
__(self
, templateObj
)
51 def warn(self
, exc_val
, code
, rawCode
, lineCol
):
52 dict = locals().copy()
54 dict['time'] = time
.strftime(self
._timeFormat
,
55 time
.localtime(time
.time()))
56 self
._errors
.append(dict)
60 """Return the list of errors."""