Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out which procedure threw an exception in Delphi?

I am using Delphi TApplication.OnException Event to catch unhandled exceptions

This works well but does not give sufficient information about where the exception happened i.e. ‘Catastrophic failure’

How can I find out which procedure made the error happened?

procedure TFrmMain.FormCreate(Sender: TObject);
begin
  Application.OnException := MyExceptionHandler;
end;

procedure TFrmMain.MyExceptionHandler(Sender : TObject; E : Exception );
begin
  LogException (E.Message);     
  Application.ShowException( E );
end;
like image 538
Charles Faiga Avatar asked Dec 07 '08 07:12

Charles Faiga


People also ask

Can you catch a StackOverflowException?

NET Framework 2.0, you can't catch a StackOverflowException object with a try / catch block, and the corresponding process is terminated by default. Consequently, you should write your code to detect and prevent a stack overflow.

What is stack over flow exception?

A StackOverflowException is thrown when the execution stack overflows because it contains too many nested method calls. For example, suppose you have an app as follows: C# Copy. using System; namespace temp { class Program { static void Main(string[] args) { Main(args); // Oops, this recursion won't stop. } } }

How do I ignore an exception in Delphi?

You can use Delphi's “advanced breakpoints” to disable exception handling around a region of code. To begin, set a breakpoint on the line of code where you want the IDE to ignore exceptions. Right-click on the breakpoint dot in the gutter and open the breakpoint-property dialog.

What causes stack overflow c#?

The most-common cause of stack overflow is excessively deep or infinite recursion, in which a function calls itself so many times that the space needed to store the variables and information associated with each call is more than can fit on the stack. An example of infinite recursion in C.


1 Answers

You can get the memory address where the exception was thrown by using the ExceptAddr variable (System unit). But if you want a stack trace you could use one of the 3rdParty tools MadExcept, EurekaLog or the open source JCLDebug (part of the JCL).

like image 135
Andreas Hausladen Avatar answered Sep 29 '22 21:09

Andreas Hausladen