kids_pro wrote:
Unfortunately I haven't got one yet.
Would you recommend a few good practise?
This is a very complex topic, and I guess the world is still waiting for
ultimate treatise on exception handling. Here is a nice checklist, though
(see
http://www-106.ibm.com/developerwork...bexcept.html):
1. If you can't handle an exception, don't catch it.
2. If you catch an exception, don't swallow it.
3. Catch an exception as close as possible to its source.
4. Log an exception where you catch it, unless you plan to rethrow it.
5. Structure your methods according to how fine-grained your exception
handling must be.
6. Use as many typed exceptions as you need, particularly for application
exceptions.
Point 1 is obviously in conflict with Point 3. The practical solution is a
trade-off between how close to the source you catch an exception and how far
you let it fall before you've completely lost the intent or content of the
original exception.
<<
Also, the chapter on exceptions in Richter's .NET Framework Programming (MS
Press) is highly recommended.
Cheers,
--
Joerg Jooss
jo*********@gmx.net