473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Exception classes with properties

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?
Jul 18 '05 #1
0 934

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
9
by: Allan Ebdrup | last post by:
Hi I'm having a discussion with another programmer about a best practice for thrownig exceptions. I want to create a rich class library with many different exception classes in their own...
4
by: Ray Cassick \(Home\) | last post by:
I am trying to create a generic logging component that will accept an exception object and create a string containing all the properties and their values available for a specific exception. My...
1
by: Daniel Klein | last post by:
When creating a custom exception that derives from ApplicationException, why is it necessary to have the 3 basic contructors, i.e. Public Sub New() Public Sub New(ByVal message As String)...
10
by: Chet Cromer | last post by:
I am creating a set of base classes and sub classes to use throughout a program I'm developing. The base class represents a generic "lookup table" from my database that contains lists of things...
3
by: Dave | last post by:
Please - anyone that can help. I am getting confusing results while trying to expose a collection from a web service. I have a webservice in which a web method accepts a collection as a...
0
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
4
by: Zytan | last post by:
I deal with a bunch of exception handlers by calling a function that writes the info to a log file. Of course, this takes in Exception, so I can pass it any exception class. But, it'd be great if...
4
by: Josh Valino | last post by:
Hi group, Is there a way in C# (.Net 3.5 FW) for me to define an abstract class that has some properties, and then in each derived class, select which properties I'd like available and which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.