473,320 Members | 2,161 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,320 software developers and data experts.

Help on Exception Handling ????

Dear all,

I am buiding a quite huge application which is devided in
quite many small functionnality that we will call modules
here to simplify.

I need to implement my exception handling routine that
need to be language dependent. I mean that all error
should be able to depend on selected language. For that I
need some good advide on what is the best way according to
your experience to handle it:

1- is it better to get an exception handling for each
modules?

2 - is it better to have a module itself called
myException that every modules gets referenced?

3 - I might need to add my own custom error message how
to do ?

Thanks for your advise
Regards
Serge
Jul 19 '05 #1
2 1848
Can't tell you which is the best way... but I've gone for an error class
that that has a static function AddError, passing in severity, error code,
error message and from which module \ function.

This gives me the flexibility later, if I decide to actually log errors,
give different messages on severity types etc...

Hope that helps.

rollasoc

"Serge Calderara" <se*************@maillefer.net> wrote in message
news:05****************************@phx.gbl...
Dear all,

I am buiding a quite huge application which is devided in
quite many small functionnality that we will call modules
here to simplify.

I need to implement my exception handling routine that
need to be language dependent. I mean that all error
should be able to depend on selected language. For that I
need some good advide on what is the best way according to
your experience to handle it:

1- is it better to get an exception handling for each
modules?

2 - is it better to have a module itself called
myException that every modules gets referenced?

3 - I might need to add my own custom error message how
to do ?

Thanks for your advise
Regards
Serge

Jul 19 '05 #2
Serge Calderara wrote:
Dear all,

I am buiding a quite huge application which is devided in
quite many small functionnality that we will call modules
here to simplify.

I need to implement my exception handling routine that
need to be language dependent. I mean that all error
should be able to depend on selected language. For that I
need some good advide on what is the best way according to
your experience to handle it:
For "depend on selected language" I assume you mean a locale (or culture)
language rather than a programming language. The internationalization story
in .NET is good in some respects by bad in others. The bad side is that it
puts the responsibility of internationalization on the developer _when the
text is created_ rather than on the code that will display the text. (If you
want to internationalize a form, this a good thing; but if you want to
internationalize an event log message, it is a bad thing because the event
log can be read by another machine in another locale.)

The good part is that you create multiple resource library assemblies (DLLs
called satellite assemblies), one for each culture. You put the localized
text messages in the assembly and associate each with an ID. You then create
a ResourceManager object which will automatically determine the culture that
the current thread uses and load the appropriate satellite. When you ask it
for a string by passing the ID, the appropriate localized string is
returned. If the code is run on a culture for which a satellite is not
available there is a fallback mechanism. For example, if you run on UK
English (en-UK) and that satellite is not available the ResourceManager will
look for generic English (en) and if that satellite is not available it will
look for neutral resources. Neutral resources are embedded as part of the
application assembly. It is important to provide neutral resources beause it
means that there will always be a message - even if it is not in the
language of the reader!
1- is it better to get an exception handling for each
modules?
Are you talking about .NET modules? In which case the answer is no. I
suspect you are talking about assemblies (library and process assemblies).
..NET localization is application based: satellite assembluies are associated
with an application.
2 - is it better to have a module itself called
myException that every modules gets referenced?
No.
3 - I might need to add my own custom error message how
to do ?


hmmm, I am not sure if you understand .NET exceptions. Each exception has a
Message property that contains details of the exception and may have other
properties. Its better to localize the exception message when you create the
exception:

if (param1 == 0)
{
Assembly assem = Assembly.GetExecutingAssembly();
ResourceManager rm = new ResourceManager("MyExceptionMessages", assem);
String msg = rm.GetString("ParamIsZero");
throw new ArgumentException(msg, "param1");
}

This means that if you catch the exception in other code and log (or
display) the exception you do not have to localize the message.

Richard
--
my email ev******@zicf.bet is encrypted with ROT13 (www.rot13.org)
Jul 21 '05 #3

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...
7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
2
by: tom | last post by:
Hi, I am developing a WinForm application and I am looking for a guide on where to place Exception Handling. My application is designed into three tiers UI, Business Objects, and Data Access...
9
by: C# Learner | last post by:
Some time ago, I remember reading a discussion about the strengths and weaknesses of exception handling. One of the weaknesses that was put forward was that exception handling is inefficient (in...
4
by: Ele | last post by:
When Exception handling disabled compiler still spits out "C++ exception handler used." Why is that? Why does it ask for "Specify /EHsc"? Thanks! c:\Program Files\Microsoft Visual Studio...
3
by: Serge Calderara | last post by:
Dear all, I am buiding a quite huge application which is devided in quite many small functionnality that we will call modules here to simplify. I need to implement my exception handling...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
4
by: DHS1 | last post by:
Hey guys. I have a lab that is due in two weeks, but I wanted to start on it now. Problem is, I'm at home during christmas break so I can't ask my professors. Here's my problem: I am given a very...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.