Throwing Exceptions

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.
 
S

S. Justin Gengo

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
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top