BreakOnExceptions?

Hi,

I use BreakOnExceptions to avoid the debugger stop each time we call a delegate created with weakAdressof. This way we avoid execution breaks every time there if the target object went away and delegate’s weak ref got nil.

But it seem like the BreakOnExceptions option is also applied to the code called by the delegate if it works.
So big parts of our code do not break on exception.

Is that a bug or a feature?

Does someone have an idea how to workaround this?

We would not need it if we would have a way to know if a weak delegate got nilled.

You can override BreakOnExceptions with the #Pragma BreakOnExceptions . Maybe that’s a solution.

I do that, but the problem is that it also affects code called in that method where I use it.

I use this:

#pragma BreakOnExceptions false try // do something that potentially can raise an exception to ignore end try #pragma BreakOnExceptions true

Yes, Massimo, we do exactly that. But what if we call in try a method which could raise exception and we want to catch it in debugger?

But you said you want to ignore that exception. Or I did not understand properly.

If I remember correctly BreakOnExceptions is scoped so exceptions will be suppressed in methods called inside of a false and true. I believe what you need to to is add

#pragma BreakOnExceptions true

at the top of each of the delegate methods.

Feature.

I want to catch the exception in the method called via delegate, but I don’t want to stop in debugger due to an invalidated weak address in a delegate.

Right, you need to re-enable BreakOnExceptions in the delegate method so it will break into the debugger. Quick example.

Shouldn’t you check the weak ref for Nil before calling and that’ll prevent your exception?