can error messages be improved or can they be overridden ?
steve at holdenweb.com
Sun Feb 22 10:14:24 EST 2009
Barak, Ron wrote:
> Hi Stef,
> You can do something like (not tested):
> self.Brick.Par [ self.EP ]['FileName'] = filename
> except IndexError,e:
> msg = "%s: '%s %s %s %d" % (e.strerror,e.filename,self.EP,self.EP,len(self.Brick.Par))
> print msg
Unfortunately this too can raise an IndexError if self.EP has less than
three elements ...
>> -----Original Message-----
>> From: Stef Mientki [mailto:stef.mientki at gmail.com]
>> Sent: Sunday, February 22, 2009 15:43
>> To: python-list at python.org
>> Subject: can error messages be improved or can they be overridden ?
>> I often get an error message like this
>> self.Brick.Par [ self.EP ]['FileName'] = filename
>> IndexError: list index out of range
>> Now it would be very welcome,
>> if the error message specified which index is out of range,
>> in this case e.g.,
>> - specifying the length of self.EP
>> - specifying the value of self.EP
>> - specifying the length of self.Brick.Par etc..
>> Is there a way to override the error message and provide this
>> information, or is it impossible ?
>> And if it's possible, am I the only one who often stumbles
>> about this problem ?
>> (I expect many people must have bounced in this problem before me ;-)
>> Stef Mientki
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list