Knowledge Base

Exception handling tools in Delphi

Introduction

Delphi comes with an excellent debugger. For regular development work, you can get by with the integrated debugger. But sometimes, you need extra information to track down an exception. Fortunately, the Delphi ecosystem provides many tools to add functionality to Delphi. In this article, we look at four external exception-handling tools.

The tools

For this analysis, we selected the following tools:

Only the Jedi library is free if you want to use these tools in commercial applications. You may also use MadExcept for non-commercial projects. MemInsight, MadExcept and Eurekalog are all in the same price range, between € 115,- and € 149,- per user.

Functionality

A great tool helps you as a developer to find and fix bugs faster. A good stack trace is essential for this. A stack trace is an overview of calls in the order they occurred up to the point where your program encounters an exception. Each item in this stack trace has information such as the name of the procedure or function, its location in the source code and the line number. This makes it very easy to find the exact place where an exception occurs.

So, let’s have a look at the available tools.

TMS MemInsight

TMS MemInsight is a relatively new tool, launched in 2022. It is a tool to help you view the run-time memory allocation, exception call stack, and thread inspection.

MemInsight consists of one component: TTMSMemInsightProfiler. You can place this component on any form or data module. The main difference with the other tools in this overview is that MemInsight gives an immediate runtime overview of your application’s statistics, exceptions and memory status, not just after an exception occurs. This makes it a useful tool during development.

It is not possible to send the stack traces automatically to a bug tracker or webservices, making it suitable mainly for you as a developer and less so for production systems.

MadExcept

Unlike MemInsight, MadExcept has no visual components you need to place on a form or data module. Instead, you can activate MadExcept on a per-project basis.

MadExcept captures exceptions after they occur in your application. You can use MadExcept to hide any access violations or exceptions, forward the stack trace to ftp, mail or web service, or display form giving the users a choice as to whether to continue the report, send, or save the bug report. In addition, extensive log files or bug reports can be stored and viewed with a separate viewer. It is not possible to get a runtime overview of memory usage or exceptions that previously occurred, as with MemInsight.

Eurekalog

Eurekalog also focuses on making any error messages or exceptions that may occur in your application more user-friendly. Although there is no free, non-commercial version available, the price is similar to MadExcept. MadExcept and Eurekalog are also very similar in functionality. However, Eurekalog does have more extensive capabilities to send stack traces and log files to bug trackers such as Mantis, Jira or GitHub.

Eurekalog has more extensive options than MadExcept, although on the core components, the two products are similar. On details, such as localisation, Eurekalog has more to offer. On the other hand, for larger projects, MadExcept gives less overhead and is faster to compile.

Jedi Debug

You can install Jedi Debug, or jclDebug, via the GetIt package manager, or via a manual install from https://www.delphi-jedi.org/

jclDebug does not, like MadExcept or Eurekalog, have a convenient installer or an easy way to configure the exception handling. Instead, you have to create and configure the debug handler manually, for example in the initialization and finalization section of your application.

Since jclDebug belongs to the open-source project Jedi, jclDebug is free to use. However, you sacrifice some functionality here, such as easy configuration of options and automatic forwarding of bug reports including stack trace. If you want full flexibility in handling exceptions, jclDebug is definitely worth considering.

Other tools

Other (open source) tools are on the market, including DebugEngine. Unfortunately, DebugEngine is not up-to-date and is no longer actively maintained. This makes it risky to use in production systems. Additionally, FastMM5, for example, only has support for JCL, madExcept and EurekaLog, so I would personally use one of these three for (production-ready) exception handling.

Finally, some tools focus more on detecting memory leaks, such as Delphi LeakCheck and FastMM. These tools do not have support for exception handling, which puts them out of the scope of this article.

Conclusion

Which tool you choose depends on your goal with these tools. If you want direct insight while developing your application as a developer, then TMS Meminsight is very useful. With a single component and without too much configuration, you can get instant insight into statistics, memory usage and stack traces for exceptions.

If you want to use exception handling in production systems, you can’t really ignore MadExcept and Eurekalog. Both products have a long and proven history, are stable and offer a lot of functionality. The choice between MadExcept and Eurekalog is personal, both products are a very valuable extension to get better insight into any runtime problems.

And if you don’t want to spend money on these tools, there is a free and open-source alternative, although you will have to build a lot of functionality yourself.

As you can see, there is a solution for every situation, which again shows that the ecosystem around Delphi is very valuable for you as a developer.

Contact

Let us help you to realise your ambitions

GDK Software UK

(+44) 20 3355 4470

GDK Software USA

+1 (575) 733-5744