473,413 Members | 1,737 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,413 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 1851
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: 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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.