Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2025-02

Catch only uncaught exceptions

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hello,

In the browser, there is a possibility to let it stop only on uncaught exceptions. IOW there is no 'try..catch' block around the exception.

This is in fact quite handy at times...

Is there some trick in the lazarus debugger that would allow us to do the same ?

Michael.

Reply by email

Martin Frb
to Michael Van Canneyt
Michael Van Canneyt wrote 11 lines
Hello, In the browser, there is a possibility to let it stop only on uncaught exceptions. IOW there is no 'try..catch' block around the exception. This is in fact quite handy at times... Is there some trick in the lazarus debugger that would allow us to do the same ?

No, not currently. And not in a simple way... well depends.

Lets assume it was implemented.

try
 ??? raise TBarException.create;
except
 ? On TFooException: ;
end;

There is an exception handler => so that would count, TBarException would only be caught if re-raised in the exception handler. The "on ..." info is afaik only available as machine code. So the debugger has no way of knowing.

Worse, the debugger is still lacking some support of finding the exception handler. It works (not nice, but works) on Windows. But not so well on Linux. So that needs to be fixed first.
And it requires the code to actually execute and go there. Basically it currently lacks understanding of SEH (it just has a quick and dirty replacement of the old code that would use breakpoints in fpc_pop_exception or what it was called). Not yet gotten round to write a proper replacement.

------------------------

I had actually started (planing / no code yet) on a different idea (a year ago), but not found the time to go on with it. And currently deferred for unknown time. (gotten into SynEdit again)

Exceptions should have all the same properties as breakpoints. You would have the
- catch all
- any self defined, such as class = TFooException
? (in the way you can currently define to ignore TFooException).

Then you could disable TFooException by disabling its "breakpoint like entry".

But the more important bit would have been, that you could have used the enable/disable group feature.
You could have non-breaking breakpoints, to mark a section of code in which you could disable the exception.
Though that is not the fastest to do, as the breakpoint triggers a lot of work, even if it continues...

Reply by email