德尔福可以告诉我这个例外的例子的名字吗? [英] Can Delphi tell me the name of the routine that threw an exception?
问题描述
procedure / function bla(); //这可以是一个单位/类
begin
code ....
这里提出一个错误 - >里面还是没有一个try-except / finally块
end;
,我会收到一条消息/对象/表示我提出错误'x'的任何东西在'bla'中。
我知道有关madexcept,还有另一种方式来捕捉异常吗?
我正在使用Delphi 7.解决方案可能适用于其他Delphi版本。
您可以使用 ProcByLevel
函数从 JclDebug.pas
单元,它是 JCL 库
在使用前必须激活选项'插入JDBG数据从Ide菜单工具 - > jcl选项中的二进制'
中。
然后你可以这样使用它
使用
JclDebug;
procedure TForm18.Button1Click(Sender:TObject);
begin
try
raise Exception.Create('Hello from'+ ProcByLevel(0));
除了
在e:Exception do
ShowMessage(e.Message);
结束
结束
,结果就是这样的
I know how to catch exceptions in delphi (try..except/finally and e.message) but I want to know if there exists an exception handling mechanism which can raise the exception and also the name of the routine which raised it. by example
procedure/function bla();//this can be in a unit/class
begin
code....
an error is raised here -> inside or not of an try-except/finally block
end;
and I'll receive an message/object/anything that indicates me that error 'x' was raised in 'bla'.
I know about madexcept, there is another way to catch exceptions as they do?
I'm using Delphi 7. Solution may be applicable to other Delphi version also.
You can use the ProcByLevel
function from the JclDebug.pas
unit wich is part of the JCL library.
before to use you must activate the option 'Insert JDBG data into the binary'
from the Ide Menu tools->jcl Options.
and then you can use it in this way
Uses
JclDebug;
procedure TForm18.Button1Click(Sender: TObject);
begin
try
raise Exception.Create('Hello from '+ProcByLevel(0));
except
on e : Exception do
ShowMessage(e.Message);
end;
end;
and the result is something like this
这篇关于德尔福可以告诉我这个例外的例子的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!