Side effects to creating but not throwing an exception

R

Rob

Are there any side effects to creating but not throwing an exception?

Thanks for your help,
Rob
 
K

Knute Johnson

Rob said:
Are there any side effects to creating but not throwing an exception?

Thanks for your help,
Rob

About the same as creating any other object I would guess.

Just for my curiosity, what are you really doing?
 
R

Rob

About the same as creating any other object I would guess.

Just for my curiosity, what are you really doing?

I have a set the exception message to a different value in one special
case. I figured I could either pass a boolean through several calls
to get to where the exception is thrown or I could examine the stack
trace to see if a particular class is in the call stack which will
tell me if I should change the exception message. It is an ugly hack,
but probably the least unpleasant of several unpleasant alternatives.

Thanks,
Rob
 
P

Patricia Shanahan

Rob wrote:
....
I have a set the exception message to a different value in one special
case. I figured I could either pass a boolean through several calls
to get to where the exception is thrown or I could examine the stack
trace to see if a particular class is in the call stack which will
tell me if I should change the exception message. It is an ugly hack,
but probably the least unpleasant of several unpleasant alternatives.

There is a third option. Throw a fixed exception based on what the
method detecting the problem knows. Higher up the stack, at the level
where you would be selecting the value of the boolean, catch it and
throw a new exception, incorporating additional data or the changed
message, with the original exception as its cause.

Patricia
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top