Exception and logging component

A

Ali-R

I'm using a .Net application to execute DTS packages within Sqlserver,I need
to have very customizable and powerful Exception maangement systems which
loggs different issues happend in the DTS package with my own errorCode. Can
somebody give me some ideas?

Thanks
 
C

Carlos J. Quintero [.NET MVP]

What kind of ideas do you want? The first thing is to understand the basics
of .NET Exceptions (try, catch, finally, throw, etc.) and to become familiar
with the existing .NET Exceptions of the Framework
(ArgumentOutOfRangeException, etc.) to reuse them or to know if you need to
create custom ones. Then, to define your strategy to deal with exceptions
and to decide how to report them (on screen, by e-mail, in the event log,
etc.).

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
A

Ali-R

Here is what I have to deal with:

I'm getting a CSV file from our clients which I need to validate it before
sending it to a DTS packages so there are two types of exceptions that might
happen:

1) Exceptions which should be thrown while parsing the CSV file
2) Exceptions which are thrown in the DTS package

Do you think I can handle both types of exceptions by implementing my own
Exception handler or by using Microsoft Exception management block?

Thanks for yuor help.
 
C

Carlos J. Quintero [.NET MVP]

Yes, it seems simple and some exception handlers will be enough. Some things
to consider:

- Add handlers for unhandled exceptions (which can be from Main thread,
manual threads, pool threads, finalizer thread, etc.).
- Notice that different exceptions need different treatment. For example,
OutOfMemoryException requires special care.
- Provide as much info as possible when reporting an exception; for example,
the line which caused an exception parsing the CSV file.
- Some times an exception wrappes an inner exception which contains the
actual cause of the exception. So, when reporting, try to use
Exception.GetBaseException() rather than the wrapper.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
A

Ali-R

Excellent notifications,Thanks very much

I'd like to log both types of Exceptions in the same place(in the same file
for instance)

What's your recommandation for that?

Thanks
 
C

Carlos J. Quintero [.NET MVP]

Once you have decided how to log exceptions, you have to code a centralized
routine to be called from wherever an exception is catched. Needless to say
that this routine must be rock-solid...in my last project, this routine
received 2 parameters to indicate how to log it: to the event log, by-email,
or both. If you have requested a way, and it fails (what should not happen,
of course), you can still use the other way to notify that the exception
notifier routine has failed, to avoid an exception being silenced.

Then, you have to code your application and do a lot of testing since you
don´t know what exceptions can occur (I think that Java methods inform the
developer what exceptions can throw, but not in .NET). When parsing, you can
expect the IndexOutOfRangeException when strings are shorter than expected,
but only testing can provide you all exceptions that can happen.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
A

Ali-R

Thanks for your suggessions.
Carlos J. Quintero said:
Once you have decided how to log exceptions, you have to code a
centralized routine to be called from wherever an exception is catched.
Needless to say that this routine must be rock-solid...in my last project,
this routine received 2 parameters to indicate how to log it: to the event
log, by-email, or both. If you have requested a way, and it fails (what
should not happen, of course), you can still use the other way to notify
that the exception notifier routine has failed, to avoid an exception
being silenced.

Then, you have to code your application and do a lot of testing since you
don´t know what exceptions can occur (I think that Java methods inform the
developer what exceptions can throw, but not in .NET). When parsing, you
can expect the IndexOutOfRangeException when strings are shorter than
expected, but only testing can provide you all exceptions that can happen.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top