Page 1 of 1

Get exception call Stack in text & leak report in Text

Posted: Mon Feb 19, 2018 8:32 am
by Tarvirdi
Dear Friends,
I am developing a console application that works 24x7 and has not the operator so events include errors should be logged in my log lib.
I have three requirements for my app that wish “MadExcept” can provide me.
1-When catch exception in try/except block, I want to have exception reason and nested called methods with line Numbers to log them (text) in my log lib (do not show your error dialog)
2-When there is unhandled exception occurs, I want to have exception reason and nested called methods with line Numbers to log them (text) in my log lib (do not show your error dialog)
3-When application terminated check memory leaks and get a report of them in text format to log them in my log lib.
I think there are standard routines that can use them directly.
Can anybody advise me?
Thanks

Re: Get exception call Stack in text & leak report in Text

Posted: Tue Feb 27, 2018 4:12 pm
by madshi
Hi there,

1. You can use GetCrashStackTrace() to get the crash stack trace. As for the "exception reason", you can ask "ExceptObject".

http://help.madshi.net/madExceptUnit.ht ... StackTrace

2. This is somewhat complicated, because if there's an unhandled exception, where do you want the crashing thread to continue running? Do you want your program to continue in this situation, anyway? In any case, you can use RegisterExceptionHandler(stDontSync) to install a little exception handler. Inside you can set "handled := true" to prevent madExcept from showing its exception dialog. Then you can access the "exceptIntf" interface to get information about the crash. E.g. you can use "exceptIntf.BugReport()" to get a full bug report, including a callback of all threads.

3. Leak reporting is not something that I recommend for your end users. It's mainly meant to be used on your development PC. In any case, you can call "SetLeakReportFile()" to tell madExcept to store the leak report into a specific file. This will be done after your EXE has already shut down, so at this point madExcept can't call your code to deliver the leak report. What you can do is look for the leak report file, when your EXE starts the next time.

Hope that helps?