29 def __init__(self, message, extra_message = None) :
30 Exception.__init__(self, message)
41 self.
traceback =
''.join( traceback.format_tb( sys.exc_info()[2], 3 ) )
47 string = self.message +
'\n'
71 def __init__(self, message, stock, action, url ):
77 message = str(message)
79 PortfolioError.__init__(self, message)
98 string =
'ParserError: ' + self.message +
'\n'
101 string +=
'stock: %s' % self.
stock +
'\n'
103 string +=
'action: ' + self.
action +
'\n'
105 string +=
'url: ' + self.
url +
'\n'
107 string +=
'traceback:\n ' + self.
traceback
118 message = str(message)
119 PortfolioError.__init__(self, message)
129 string = self.message +
'\n'
136 string +=
'url: ' + self.
url +
'\n'
138 string +=
'traceback:\n ' + self.
traceback
145 if __name__ ==
"__main__":
153 print "Test PortfolioError 1 argument "
156 except PortfolioError
as e:
157 print "Got a PortfolioError"
158 print "e.args ", e.args
160 print "e.message ", e.message
162 print "\nTest PortfolioError 2 argument "
165 except PortfolioError
as e:
166 print "Got a PortfolioError"
167 print "e.args ", e.args
169 print "e.message ", e.message
171 print "\n== Test ParserError"
173 raise ParserError(
"An error from Parser",
"An other error")
174 except ParserError, e:
175 print "\nGot a ParserError"
177 print "e.args ", e.args
178 print "e.errors ", e.errors
179 print "e.message ", e.message
181 print "\n== Test ParserError catched as PortfolioExcpetion"
183 raise ParserError(
"An error from Parser",
"An other error")
184 except PortfolioError, e:
185 print "\nGot a PortfolioError"
187 print "e.args ", e.args
188 print "e.errors ", e.errors
189 print "e.message ", e.message
Base class of the custom exceptions.
def get_format_string
Produce more informative error message, including traceback.
Specific exception related to the web query (Utils.WebQuery)
Derived class specific to the parsers.