如何找出哪个程序在Delphi中抛出异常? [英] How can I find out which procedure threw an exception in Delphi?

查看:413
本文介绍了如何找出哪个程序在Delphi中抛出异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Delphi TApplication.OnException事件来捕获未处理的异常

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

这个工作很好,但是没有提供关于发生异常发生的地方的足够信息
ie'灾难性失败

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;


推荐答案

您可以获取抛出异常的内存地址通过使用ExceptAddr变量(系统单位)。但是如果你想要一个堆栈跟踪,你可以使用第三方工具MadExcept,EurekaLog或开源JCLDebug(JCL的一部分)。

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).

这篇关于如何找出哪个程序在Delphi中抛出异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆