Search code examples
delphi-7

how to find "File name and line number of Exception" in runtime


is there any component in Delphi7 to show more information about an exception in runtime like:

  1. exception message and class
  2. ".pas" file name
  3. line number of exception

This information is very important when running the application on customer site.


Solution

  • The Delphi 7 compiler does not include the filename or line number in the DCU. (Later versions make the filename available through RTTI, but it's not present in D7.)

    You could use an exception handling package such as MadExcept (free for non-commercial use, and reasonably priced for a commercial version), EurekaLog (commercial, but I have no info on cost), or the JEDI JclDebug unit (Open Source), which can use the debugging information and information from a linker map file to provide a stack trace from the exception back. That stack trace includes the unit and line number (as well as the method or procedure name) where the exception occurred.