Re: Exception Messages

2012-10-15 Thread Steven D'Aprano
On Mon, 15 Oct 2012 09:00:15 -0700, Wanderer wrote: > How do you get Exceptions to print messages? I have an exception defined > like this > > class PvCamError(Exception): > def __init__(self, msg): > self.msg = msg Please don't invent yet another interface for exception messages. E

Re: Exception Messages

2012-10-15 Thread Terry Reedy
On 10/15/2012 12:22 PM, John Gordon wrote: In MRAB writes: Why wasn't the message printed out? You didn't add a __str__ method: class PvCamError(Exception): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg Wouldn't PvCamError i

Re: Exception Messages

2012-10-15 Thread Wanderer
On Monday, October 15, 2012 1:34:24 PM UTC-4, MRAB wrote: > On 2012-10-15 18:18, Wanderer wrote: > > > On Monday, October 15, 2012 12:34:53 PM UTC-4, MRAB wrote: > > > > > >> > > >> Yes, but you've put the message in msg, and Exception doesn't have that > > >> > > >> attribute. > > >> > > >

Re: Exception Messages

2012-10-15 Thread MRAB
On 2012-10-15 18:18, Wanderer wrote: On Monday, October 15, 2012 12:34:53 PM UTC-4, MRAB wrote: Yes, but you've put the message in msg, and Exception doesn't have that attribute. That's weird. I got this Exception class definition idea from this post by Guido van Rostrum, Where he gives t

Re: Exception Messages

2012-10-15 Thread Wanderer
On Monday, October 15, 2012 1:18:52 PM UTC-4, Wanderer wrote: > On Monday, October 15, 2012 12:34:53 PM UTC-4, MRAB wrote: > > > > > > > > Yes, but you've put the message in msg, and Exception doesn't have that > > > > > > attribute. > > > > > > > That's weird. I got this Exception cla

Re: Exception Messages

2012-10-15 Thread Wanderer
On Monday, October 15, 2012 12:34:53 PM UTC-4, MRAB wrote: > > Yes, but you've put the message in msg, and Exception doesn't have that > > attribute. > That's weird. I got this Exception class definition idea from this post by Guido van Rostrum, Where he gives this main function to look like

Re: Exception Messages

2012-10-15 Thread Dave Angel
On 10/15/2012 12:34 PM, MRAB wrote: > On 2012-10-15 17:22, John Gordon wrote: >> In MRAB >> writes: >> >>> > Why wasn't the message printed out? >>> >>> You didn't add a __str__ method: >> >>> class PvCamError(Exception): >>> def __init__(self, msg): >>> self.msg = msg >>> def

Re: Exception Messages

2012-10-15 Thread MRAB
On 2012-10-15 17:22, John Gordon wrote: In MRAB writes: > Why wasn't the message printed out? You didn't add a __str__ method: class PvCamError(Exception): def __init__(self, msg): self.msg = msg def __str__(self): return self.msg Wouldn't PvCamError inherit

Re: Exception Messages

2012-10-15 Thread John Gordon
In MRAB writes: > > Why wasn't the message printed out? > > You didn't add a __str__ method: > class PvCamError(Exception): > def __init__(self, msg): > self.msg = msg > def __str__(self): > return self.msg Wouldn't PvCamError inherit __str__() from Exception? --

Re: Exception Messages

2012-10-15 Thread MRAB
On 2012-10-15 17:00, Wanderer wrote: How do you get Exceptions to print messages? I have an exception defined like this class PvCamError(Exception): def __init__(self, msg): self.msg = msg But when the error is raised I get this: Traceback (most recent call last): File "C:\P