0

I'm creating an error report generator as part of a global exception handler. Right now I'm relying on the user to tell us what exactly they were doing when the exception happened.

I'm already adding the "exception.message" string to the report, but is there any way to grab the name of the procedure or the call stack "log" so I can add it to the report as well?

  • 1
    Related? https://stackoverflow.com/questions/2817699/how-to-get-the-name-of-the-current-procedure-function-in-delphi-as-a-string and https://stackoverflow.com/questions/1301254/how-to-get-current-methods-name-in-delphi-7 – Andreas Rejbrand Jan 10 '22 at 17:51
  • 5
    To get the call stack, you need a 3rd party solution like MadExcept, JclDebug, etc (unless you want to walk the stack yourself manually). Although the `Exception` class has a `StackTrace` property, it doesn't actually do anything by default, as Embarcadero does not provide an implementation for it, requiring 3rd parties to hook their own implementation into it (nobody knows why, as one would think the compiler vendor would be the best choice to provide an implementation!). – Remy Lebeau Jan 10 '22 at 18:04
  • @AndreasRejbrand Yes, but no. I should have been more specific, apologies. Unfortunately, implementing the solutions from either of the two threads isn't something that I'm able to dedicate time to at the moment considering project size and hours involved. The basic exception class has the StackTrace and StackInfo properties. Is there no way to convert the information contained into a usable string? – John Weiland Jan 10 '22 at 18:14
  • 1
    "The basic exception class has the StackTrace and StackInfo properties. Is there no way to convert the information contained into a usable string?" They are provided for tools like madExcept, Eureka, JCL, etc. to use. They won't contain anything. If you haven't got any time, you should do something else, because what you are trying to do requires time and commitment. – David Heffernan Jan 10 '22 at 18:38
  • 2
    Buy (or get) one of the tools mentioned, and save yourself some headaches and your boss a lot of money (not your hours wasted)! – Delphi Coder Jan 10 '22 at 19:02

0 Answers0