I am using MadExcept to debug my applications. It's an excelent framework though when a exception ocurrs on a try finally block it still displays that ugly box and the user thinks the app has crashed.
How can i remove that ? Is there a way ?
Sounds like it's working as designed. A try/finally block does not catch exceptions; it ensures that proper cleanup can be done even if an exception is raised.
If you want to handle an exception, you need to use a try/except block instead.
Related
I am developing an application and I have to submit an error report, I have to save all errors I face in database or word file, etc. Exceptions have to be saved in order to know what kind of exceptions we are facing and to fix them later on.
I have to write code in one place to catch any error that happens. Can anybody help me in this? Where do I write this code and even what is the code to be written in order to achieve my aim?
Here are a couple of links that discuss catching exceptions:
Xcode all exceptions breakpoint.
Installing exception handler
Hope that helps!
Is there a way to disable all the dialog boxes when an exception or error occurs(like access violations, indy socket errors, timeouts etc.)? They are thrown sometimes in my program, but these errors aren't fatal in any way and can be ignored, just the dialog boxes are disturbing. I use Delphi 7.
If you just don't wont to show the exception window then go to:
Tools/Options/Debugger Options/Language Exceptions and disable CheckBox Notify on language exceptions. That is walid for Delphi 2010.
(I don't remember if it is the same CheckBox in Delphi 7).
EDIT:
In some cases the exceptions are unavoidable, specially when we are working with unknown files from internet. So, I believe that your exceptions are handled properly under Indy, just switch-off Notify on language exceptions
You can customize Application.OnException event. But IMVHO...
Application.OnException suits best to log exceptions which you forgot to handle.
Application.OnException should be used to catch exceptions only when you desperately need performance (in this case you should anticipate broken execution paths).
And:
Access violations are fatal errors - you have to trace and get rid of all AV's.
You can't hide exception dialogs just by Application.OnException override - you should use try finally/except in right way.
Bypass the Application.OnException event. However I would NOT recommend hiding every exception, IMHO that is poor design.
# GJ - Delphi 2007 has that check box. But again as was mentioned above, access violation ain't the kind of exceptions that one should ignore.
We use TWebBrowser in our application.
on some of my customers computers (IE9/Win7) after my app terminates, it throws an Exception: "Access violation at address XXXX in module 'mshtml.dll'. Read of address XXXX" with endless loop of exception messages... very ugly :/
this only happens on very few computers (so far with only IE9/Win7).
I cannot reproduce this exception on my PC.
I also use JclDebug which is the last unit defined in my main dpr uses clause - it is not catching this exception.
How to completely supress this Exception?
The application is written in D5.
Wild guess... there is a callback (event) from IE when your Application is in the destructor and your TWebBrowser is (at least partially) destroyed.
You can try to explicitly Free the TWebBrowser earlier, see if you have any event handler that could mess around, make sure you use Release on the form that holds it...
Hard to tell without having the code.
I've multithreaded application where new TSQLConnection is created for each thread. If I try to use tracing (TSQLConnection.SetTraceEvent or TSQLMonitoring) I get the trace results as expected, but after that the main thread seems to beserk when I try to use any database functionality. Application throws excpetion "access violation at 0x004dffcf: write of address 0xfffffff2" and the call stack in IDE shows repeating lines of "7c90327a ntdll.RlConvertUlongToLargerInteger + 0x3c" and "7c90e48a ntdll.KiUserExceptionDispatcher + 0xe", and the top line is "Controls.ReadControlName(???)".
So, is the tracing function buggy and doesn't work with multithreaded application or is there hidden bug in my application? How to find out?
I'm using Delphi 2007.
Edit It looks like the exception is raised even with two separate connection in main thread. I'll try to create test application.
Problem solved, I had old (and apparently buggy) version of InterXpress driver loaded, I just didn't realize that it is part of the problem.
We have a Delphi 2007 COM component being executed from an ISAPI app. The COM component is hanging the app because it is attempting to display a MessageBox(). The call to MessageBox() must be occurring in the Delphi RTL becase it is not in our user code.
The app hangs, of course, because there is no one logged in at the server to clear the MessageBox().
How do we configure our Delphi project so that the Delphi RTL does not attempt to display MessageBox() on exception?
Write your own exception handler and attach it to the Application.OnException event. If an OnException event handler is present, Application won't use its default MessageBox routine. The signature is defined as:
TExceptionEvent = procedure (Sender: TObject; E: Exception) of object;
If this is a server, you'll probably want to write the exception information to a log, and possibly return some error to the user.
What does the messagebox say? I'm assuming it's an exception. Why don't you put an exception handler around the code in the COM component, and log the exception in a different way? (E.g., using the Event Log). And/or fix the problem that's leading to the exception in the first place.
I don't know of any direct way in Delphi but what you can do is write a small script in AutoIT/AutoHotKey and keep that script running in system tray, so that it will automatically close the MessageBox.
Believe me it is very simple.
http://www.autoitscript.com/autoit3/index.shtml
http://www.autohotkey.com/
HTH
Is it possible to compile the application as a Console app? I'm not sure if you can do this and still have it contain COM object, this would prevent message dialogs from being shown I'm sure.
Just a thought.
I've created a unit to hook MessageBox/MessageDlg calls (via detouring), so I can suppress these calls in a Windows Service (to avoid "hanging" of my service dll because of some stupid code of someone else with a messagebox call in it).
If you want it, I can search this unit and send it to you.