err.raise inside catch?

  • Thread starter Thread starter Coder
  • Start date Start date
C

Coder

I would like to use err.raise(x) within a catch block to send an exception
back to the calling function or cain of functions. Is this ok to do? I know
if i dont use try catch fail in the child function that it will send an
exception to the calling function but i want to have error handling in all
chain functions.

any MSDN documentation on this?
 
I wouldn't mix unstructured and structured handlers in my code. Exceptions
and Error aren't the same class.

If you trap an exception, you can throw it again. In your scenario, you
could define a CustomException called MyException

Trap a specific exception in your routines, but only respond to MyException
at the top level handler. Everything else, make sure you don't trap
MyException.

The "I want to have error handling in all chain functions" is something you
might want to re-consider. If you aren't handling specific things and
responding to them specifically, I think you can get yourself in trouble.
There are many functions where nothing other than broad
OutofMemoryExceptions could occur. Unless you are targeting exceptions very
specifically, I'm not sure having handlers in every method is getting you
anything.

You can always use the Diagnostics.StackTrace to find out what happened...

Unless your code is that targeted for exceptions, I'd probably revisit my
original premise.'


Let me know if you have any questions.

Cheers,

Bill
 
Coder said:
I would like to use err.raise(x) within a catch block to send an exception
back to the calling function or cain of functions. Is this ok to do? I know
if i dont use try catch fail in the child function that it will send an
exception to the calling function but i want to have error handling in all
chain functions.

any MSDN documentation on this?

You may find this helpful:

Handling and Throwing Exceptions
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
ml/cpconbestpracticesforhandlingexceptions.asp)
 
Back
Top