473,387 Members | 3,781 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,387 software developers and data experts.

Advantages of pushing XML in custom Exception Library!

Hi there,

I had been wondering for a while. I am building a very efficient Custom Exception Library. But i wasn't that sure whether i should be using XML or not.

There are 3 ways which i thought off.

1) The tradional way, how my office people handles exception in C language.

Exceptions are stored in enum

typedef enum
{
ERR_PORTDEAD = -50,
ERR_ONHOLD,
OK = 0
} STATUSERROR;

They do validations by;

if (CheckStatusPort(portNumber))
return ERR_PORTDEAD;

once detect to the client side, you had to manually concanenate the error message with a description. Troublesome.

I don't like this way.

2) So yesterday, i think of pushing my exceptions messages and stored into hashtable.

Example,

Key = -50
Value = "Error Port Dead"

Hashtable table = new Hasthtable();
table.Add(-50, "Error Port Dead");

Just keep on adding.

Once i want to do this;

If (CheckStatusReport(portNumber))
throw new CustomeException(table[-50]);

So at the end it throws out everything.

3) But the problem, is all the codes need to be manually written in C#.

Is there a way? XML or Text File. Whatever.

<xml>
<Error>
<Type>Port</Type>
<ID>-50</ID>
<Desc>Port is dead</Desc>
<Solution>Additional - cool!</Solution>
</Error>
</xml>

Somehow you will load this inside the class library,

throw new Exception((get_from_the_xml_file_with_key_-50));

What do you think?

At least in future, they can change the xml file without recompiling.

At the end of the day, i need to achieve a better, efficient of way of error handling.

Of course i am building a custom exception class that inherits from System.ApplicationException.

Can anyone shed their personal comments please based on their experiences?

Thanks.
--
Regards,
Chua Wen Ching :)
Nov 16 '05 #1
0 1212

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

Similar topics

6
by: Flare | last post by:
Hi i just read: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/exceptdotnet.asp Wich is interesting reading by the way. But. I have'nt used exception very much to...
6
by: Steve Amey | last post by:
Hi all I want to be able to throw a custom error up the call stack. I have looked around and it seems as though it's possible, but I can't get it to work :o( Below is some sample code. ...
4
by: John Dalberg | last post by:
I noticed the starterkits timetracker & issue tracker load data from a database into custom collections (arraylists) which bind to a datagrid. What are the advantages of using custom collections...
1
by: David Herbst | last post by:
Enterprise Library Jan 2006 with Visual Studio 2005 on Windows 2000 Server sp4. My custom exception formatter fails with a "Unable to handle exception: 'LoggingExceptionHandler'." exception. ...
4
by: asanford | last post by:
http://msdn2.microsoft.com/en-us/library/ds492xtk.aspx Is this the following excerpt from the above page incorrect, or is there a bug in the .net 2.0 implementation? Or perhaps I have something...
3
by: matko | last post by:
This is a long one, so I'll summarize: 1. What are your opinions on raising an exception within the constructor of a (custom) exception? 2. How do -you- validate arguments in your own...
3
by: =?Utf-8?B?Vk1J?= | last post by:
How can I catch an error and throw the exception message plus some custom text? For example, I'd like to do something like this: try { //generate error } catch { //throw ex + " my custom...
5
by: Alias | last post by:
Hi - I'm trying to implement a custom RoleProvider based on the SqlRoleProvider. I keep receiving a an error that it can't load type 'MyRoleTest.MyRoleProvider' when trying to load my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.