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

Exception Handling Approach ?

I am developing a new project in which we should have a good Exception
Handling. Ive seen there is a Exception Handling App Block in Enterprise
Library, also I could use the Try-Catch structure itself...
What would be the best Approach ?
Aug 4 '06 #1
3 1256
You will be using both. Some exceptions you expect (and handle) other ones
you don't in which case they should fall to your unhandled exception
handler. Just be explicit as possible in your try catches ..

ex:

BAD

try {
File.Open ( ... )
}
catch(Exception Ex) {
MessageBox.Show("Could not open file " + Filename);
}

GOOD
try {
File.Open ( ... )
}
catch(FileNotFoundException Ex) {
MessageBox.Show("File not found " + Filename);
}

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Bruce One" <ra**@virtualsoftware.com.brwrote in message
news:E8**********************************@microsof t.com...
>I am developing a new project in which we should have a good Exception
Handling. Ive seen there is a Exception Handling App Block in Enterprise
Library, also I could use the Try-Catch structure itself...
What would be the best Approach ?

Aug 4 '06 #2
Greg,
the example u posted does not use EntLIbrary, right?
I need to understand in which cases I would use EntLibrary
ExceptionHandling...

"Greg Young" wrote:
You will be using both. Some exceptions you expect (and handle) other ones
you don't in which case they should fall to your unhandled exception
handler. Just be explicit as possible in your try catches ..

ex:

BAD

try {
File.Open ( ... )
}
catch(Exception Ex) {
MessageBox.Show("Could not open file " + Filename);
}

GOOD
try {
File.Open ( ... )
}
catch(FileNotFoundException Ex) {
MessageBox.Show("File not found " + Filename);
}

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Bruce One" <ra**@virtualsoftware.com.brwrote in message
news:E8**********************************@microsof t.com...
I am developing a new project in which we should have a good Exception
Handling. Ive seen there is a Exception Handling App Block in Enterprise
Library, also I could use the Try-Catch structure itself...
What would be the best Approach ?


Aug 4 '06 #3
That example for another exception would fall out to the default exception
handler ...

The entlib is often used with a default exception handler ..

Aside from that I would recommend a read through one of the many articles
available such as http://www.devx.com/dotnet/Article/31463

Cheers,

Greg
"Bruce One" <ra**@virtualsoftware.com.brwrote in message
news:25**********************************@microsof t.com...
Greg,
the example u posted does not use EntLIbrary, right?
I need to understand in which cases I would use EntLibrary
ExceptionHandling...

"Greg Young" wrote:
>You will be using both. Some exceptions you expect (and handle) other
ones
you don't in which case they should fall to your unhandled exception
handler. Just be explicit as possible in your try catches ..

ex:

BAD

try {
File.Open ( ... )
}
catch(Exception Ex) {
MessageBox.Show("Could not open file " + Filename);
}

GOOD
try {
File.Open ( ... )
}
catch(FileNotFoundException Ex) {
MessageBox.Show("File not found " + Filename);
}

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Bruce One" <ra**@virtualsoftware.com.brwrote in message
news:E8**********************************@microso ft.com...
>I am developing a new project in which we should have a good Exception
Handling. Ive seen there is a Exception Handling App Block in
Enterprise
Library, also I could use the Try-Catch structure itself...
What would be the best Approach ?



Aug 4 '06 #4

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...
28
by: Frank Puck | last post by:
Meanwhile there are at least 8 years that compilers exist, which provide a working implementation of C++ Exception Handling. Has anything changed meanwhile? From my point of view nothing has...
4
by: zzfreddybb | last post by:
We are using HP aCC compiler on a HP Itanium box ( 11.23) We are having some severe performance hits using exception handling ( try/catch ) scenarios. The online aCC documentation says: HP...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
6
by: Vadivel Kumar | last post by:
I've a problem in handling a custom exception The following is my custom exception class: public class AppException : public Exception { public AppException (string message, Exception...
14
by: Rex | last post by:
Re: Looking for Tips/Writeup on overall approach to Exception Processing Hi All - I am fairly new to C# and am wondering how to best implement (overall) Exception Processing within my...
14
by: jehugaleahsa | last post by:
Hello: As an avid reader of C++ books, I know a lot of programmers out there are confronted with the challenge of exception safety. For those who don't know what it is, it is writing code in...
35
by: eliben | last post by:
Python provides a quite good and feature-complete exception handling mechanism for its programmers. This is good. But exceptions, like any complex construct, are difficult to use correctly,...
16
by: john6630 | last post by:
Coming from the .Net world, I am used to the try...catch...finally approach to error handling. And PHP 5 now supports this approach. But I am not clear what happens to unhandled errors/exceptioins?...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.