Throwing Exceptions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have Sub2 that I call from Sub1

If Sub2 evaluates to false I throw a custom exception e.

If mVal = True The
Throw New exCustomExceptio
End I

I then catch this in Sub1 in my catch like..

Catch exCustom as exCustomExceptio
........bla bl

My question is-

Should I also be catching it in Sub2 and rethrowing it

Thanks
Clive.
 
Clive,

The answer is: it depends. Will another piece of code break if this
exception occurrs. If the exception is completely handled in the original
try catch then no need to re-throw it, but if it's occurrence could break
something else you may want to throw it in order to deal with a problem
there.

Be careful not to throw too many exceptions! They use a lot of resources. So
you should never throw an exception if you don't need to.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Back
Top