Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Exception classes with properties

Thread Tools

Exception classes with properties

Gus Tabares
Posts: n/a
Hello all,

I'm curious as to whether or not this is supported. I want to be able
to have an exception class that has properties. It seems as though
subclassing both Exception and object does not work. Like in the
following code:

class TestExcn(Exception, object):

def __init__(self, id = 'test_id'):
self.args = [id]

def set_id(self, id):
self.args[0] = id

def get_id(self):
print "Test"
return self.args[0]

id = property(get_id, set_id)

If I instantiate this class and try to raise the instance, I get a
TypeError. Is it possible to have an exception class with properties?
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
CompositeControls: ViewState properties w/ Mapped properties probl =?Utf-8?B?Q2hyaXN0b3BoZSBQZWlsbGV0?= ASP .Net 1 01-19-2006 09:19 AM
Making Custom Control Properties Visible in Visual Studio's Properties Palette Nathan Sokalski ASP .Net 0 10-17-2005 02:05 AM
Problems parsing when Kent Lichty Java 0 04-16-2004 03:08 PM