Can Delphi tell me the name of the routine that threw an exception?

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(' from '+ProcByLevel(0)); except on e : Exception do ShowMessage(e. Message); end; end and the result is something like this.

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(' from '+ProcByLevel(0)); except on e : Exception do ShowMessage(e.

Message); end; end; and the result is something like this.

That's what I meant when I mentioned Jedi. But it is not a built-in Delphi library. – Trinidad Nov 10 '10 at 20:02.

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: FastMM Jedi MadExcept With those you can get a snapshot of the call stack when an exception happens.

God bless.

EurekaLog is also an excellent tool, on par with MadExcept.

Also look at JCLDebug's JCLLastExceptStackListToStrings() which gives you a nice stack dump of the point of exception. And like TheNewbie noted: you get this by setting TApplication. OnException to be the address of your error handler.

No, Delphi doesn't have any built-in "get the name of the current function" feature. MadExcept or similar products are probably the best way to get meaningful names in error reports.

– Mason Wheeler Nov 10 '10 at 18:32 +1; no you didn't. – Jeroen Pluimers Nov 10 '10 at 18:55 There's someone lately downvoting just because they don't like your answer, not because it is actually wrong. – ldsandon Nov 10 '10 at 19:02.

MadExcept is the best solution I've found so far, of course, but if your needs are not too fancy and your project is commercial, then you should check Project JEDI's JCL (especially JclDebug. Pas). There you'll find many helpful routines.It supports .

MAP files, TurboDebugger symbols, etc. Also, with it you can embed the debug info (as with MadExcept). You might also want to look into TApplication. OnException (and related).

Have a look at this question Unhandled exceptions in delphi.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions