1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import sys
17 import traceback
18
19 try:
20 from cStringIO import StringIO
21 except ImportError, e:
22 from StringIO import StringIO
23
24 from muntjac.terminal.error_message import IErrorMessage
25
26
27 -class SysError(RuntimeError, IErrorMessage):
28 """C{SystemError} is a runtime exception caused by error in
29 system. The system error can be shown to the user as it implements
30 C{IErrorMessage} interface, but contains technical information
31 such as stack trace and exception.
32
33 SystemError does not support HTML in error messages or stack traces.
34 If HTML messages are required, use {@link UserError} or a custom
35 implementation of L{ErrorMessage}.
36
37 @author: Vaadin Ltd.
38 @author: Richard Lincoln
39 @version: 1.1.2
40 """
41
43 """Constructor for SystemError with error message and/or causing
44 exception specified.
45
46 @param args: tuple of the form
47 - ()
48 - (message)
49 1. the textual error description.
50 - (message, cause)
51 1. the textual error description.
52 2. the throwable causing the system error.
53 - (cause)
54 1. the throwable causing the system error.
55 """
56
57 self._cause = None
58
59 nargs = len(args)
60 if nargs == 0:
61 super(SysError, self).__init__()
62 elif nargs == 1:
63 if isinstance(args[0], Exception):
64 self._cause = args[0]
65 super(SysError, self).__init__()
66 else:
67 super(SysError, self).__init__(args[0])
68 elif nargs == 2:
69 message, cause = args
70 super(SysError, self).__init__(message)
71 self._cause = cause
72 else:
73 raise ValueError, ('too many arguments: %d' % nargs)
74
75
79
80
82 """@see: L{IPaintable.paint}"""
83
84 target.startTag('error')
85 target.addAttribute('level', 'system')
86
87 message = self.getHtmlMessage()
88
89 target.addXMLSection('div', message,
90 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd')
91
92 target.endTag('error')
93
94
124
125
127 """Gets cause for the error.
128
129 @return: the cause.
130 """
131 return self._cause
132
133
136
137
138 - def addCallback(self, callback, eventType=None, *args):
140
141
144
145
148
149
152
153
156
157
160
161
163 raise NotImplementedError, \
164 'Setting testing id for this Paintable is not implemented'
165