Can Delphi tell me the name of the routine that th

2020-02-29 06:41发布

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.

7条回答
放我归山
2楼-- · 2020-02-29 07:20

Libraries like MadExcept adds metadata to the application so it can map an address to a unit and function name.

Delphi doesn't do that automatically and does not provide a mean to do directly that, it just provides the address which raised the exception.

Some alternatives to do what you want are:

With those you can get a snapshot of the call stack when an exception happens.

查看更多
登录 后发表回答