Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I ignore an exception only once?

When an exception occurs the debugger gives me the following message:

enter image description here

I can choose to ignore the exception by checking ignore this exception type.
However doing this ignores this exception in all future projects, which is worse than useless because I don't want to ignore exceptions in every project; I just want to ignore them in this run.

Using the ToolsAPI, is there a way to:

A - ignore exceptions for this run only, or
B - ignore exceptions just for this project, or
C - restore the ignore exception settings when I restart Delphi?

If I can do A, B or C my problem is solved.

I know the ignore exception data is stored in:

HKEY_CURRENT_USER\Software\Embarcadero\BDS\17.0\Debugging\Embarcadero Debuggers\Language Exception Classes

My preferred option would be to use the ToolsAPI to fixup the messagebox and add a ignore this exception for this session only checkbox.
But if that's not available I'm fine with messing about with the registry.
If I do fall back to the registry, I would like to force Delphi to reload the settings so I don't have to restart the IDE.

For the record I'm using Seattle, but I'd prefer this to work from 2007 onwards.

I checked the ToolsAPI, but IOTAFileFilterWithCheckEncode looks unrelated and I think IOTABreakpoint80 only applies to breakpoints set by a user.

I don't have source yet, because I'm not sure what I want is possible using the ToolsAPI, and if it isn't I'll just fallback to using an external app that records the above registry key, starts Delphi and restores the registry key. I'm hoping there's a cleaner way though.

like image 940
Johan Avatar asked Jun 05 '16 13:06

Johan


People also ask

Can you ignore an exception?

It is extremely easy to ignore exceptions, you simply surround your exception throwing code with a try and empty catch block. Exceptions are thrown when exceptional circumstances are experienced so by ignoring exceptions we are opening ourselves up for problems.

How do I ignore specific exceptions?

Sometimes, you may want to ignore an exception thrown by your Java program without stopping the program execution. To ignore an exception in Java, you need to add the try... catch block to the code that can throw an exception, but you don't need to write anything inside the catch block.

How do I ignore a specific exception in Python?

Let's say you want to ignore NameError, then you can just give continue or pass . Alternatively, you can also raise an exception. So you can use a combination of all this to get you what you want.

Can you ignore a checked exception in Java?

No, it raises a compiler error. Being a checked exception, you must either catch it or propagate it by declaring your method as potentially throwing it.


1 Answers

Unfortunately Exception ignoring settings are global IDE settings and not per project settings so whenever you are changing them that changes would affect all of your projects.

I wish Embarcadero would add this into project options so that we could have different ignore exception settings for different projects.

Any way after you check ignore this exception type and click either Continue or Break button the global IDE settings are changed and mentioned exception is added into Exception types to ignore list under
Options->Debugger Options->Embarcadero Debugger->language Exceptions

Exception types to ignore

In my case I added EDivByZero exception as an example.

Later on you can just check or uncheck the check box in front of certain exception to control whether Delphi IDE would ignore it or not.

Now is it possible to change these setting using ToolsAPI? That I don't know since I don't have any experience of working with ToolsAPI.

I hope I might have at least point you in the right direction.

like image 197
SilverWarior Avatar answered Sep 19 '22 16:09

SilverWarior