I really don't understand what you are missing but this is the way I would look at it 
for a Desktop app.

Do this in the UI where events start, not in dll's or class unless you need to trap an 
error.

Try
        execute stuff
Catch 
        show the error to the user by either a messagebox or a custom display form 
(this can include a cut and paste button and/or an email button to email support), and 
log the error in a text file (xml text file if your hightech).
finally
        handle things like cursors.


for you custom errors, create your own exceptions in a sererate dll and any assembly 
that needs one, just reference the dll.  Then you can easily create your custom 
exceptions and catch them later.



-----Original Message-----
From: Sam Gentile [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 28, 2002 2:38 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Need a good real-world C# Exceptions Resource or
Stategy for Library


I have just been poring through C# books and no one seems to address this
well. Sure, otherwise great books like Jesse Liberty's "Progarmming C#" talk
about Exceptions but all the examples are too trivial. The examples just
shoot out an "I am here" kind of thing in the catch handler. Actually some
C# books don't even discuss it!! I need something more.

Lets suppose I am/have creating a C# library of classes in a namespace. I
want to put in full exception handling. I have some circumstances where I am
creating files and reading them with System.IO classes, I am doing a lot of
things with System.Xml. The thing is that I want to define and implement a
sound exception processing strategy. Obviously, I don't really want to
handle exceptions in a library by putting up System.Console.WriteLine("Can't
open file"). I want to throw them up to the caller, but what? Suppose I
catch an ArgumentNullException on a FileStream constructiuon. Does it make
sense to define my custom exceptions and throw those up? Are there any good
C# resources that show real exception processing/good pratices?



---------------------
Sam Gentile
.NET Consultant
Co-author: Wrox Visual C++ .NET: A primer for C++ developers
BLOG: http://radio.weblogs.com/0105852/
http://www.project-inspiration.com/sgentile/DotNet.htm
http://www.project-inspiration.com/sgentile/
---------------------------




_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to