misc Posted July 4, 2014 Share Posted July 4, 2014 I have an application that uses ZeosDb to access a mySQL database. When mySQL is restarted on the server, the app looses connection, and "Dataset.Active:= true;" raises an "ODBC call failed" exception, passing into the catch-all below: procedure TUniServerModule.UniGUIServerModuleException(Sender: TUniGUIMainModule; AException: Exception; var Handled: Boolean); begin if LikeList(AException.Message, ['*odbc*', '*sql server*']) then begin ShowMessage(rsDBReconnect); //<--not shown end else ShowMessage(Sender.Name + ': ' + AException.Message); //<--shown Handled:= true; end; Problem 1: the red message above is not displayed, even though we definitely pass here in debug mode. If a non-odbc error is encountered, the blue message is shown. Problem 2: after this event, all uniGUI menus are gone and the app does not really work anymore My guess is, that the exception itsself already puts the application into some strange state, where things like menus & dialogs dont work anymore. Any ideas how I can handle this? Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 4, 2014 Administrators Share Posted July 4, 2014 OnException event is only for non-visual code. ShowMessage() and etc. will not work here. It may occasionally work, but as I said this exception not always run synchronous with visual GUI. If you want to catch the exception do it where you set DataSet.Active := True; Link to comment Share on other sites More sharing options...
misc Posted July 7, 2014 Author Share Posted July 7, 2014 Hello Farshad, as I am working heavily with databases, it is unfortunately very hard to catch every DB exception where it occurs. Also, when an exception occurs the app goes into some strange crash state, where the menus and some of the controls no longer work. Do you know anything about this? Why does it happen and how can I prevent it? Or in other words: if a database connection exception occurs (Zeos controls), why do the unigui menus no longer work. What does one thing have to do with the other?! And how can I handle the message problem? Any tricks? If I could show a message in the general UniGUIServerModuleException, then I could ask the user to restart the app, or even do it for him. At the moment, due to the crashed state after an exception, the user experiences the uniGUI application as unstable and with undetermined outcome. 1 Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 7, 2014 Administrators Share Posted July 7, 2014 why do the unigui menus no longer work. What does the above in technical terms mean? Link to comment Share on other sites More sharing options...
misc Posted July 8, 2014 Author Share Posted July 8, 2014 They are empty, ie only a tiny square pops up. I suppose that means they are empty. Or in not so technical terms: It seems the DB connection exception eats up the unigui menu items ;-) Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 8, 2014 Administrators Share Posted July 8, 2014 Which menu items? Those in web app? Link to comment Share on other sites More sharing options...
misc Posted July 11, 2014 Author Share Posted July 11, 2014 I've attached a screenshot to illustrate the problem. Thanks for the effort. Link to comment Share on other sites More sharing options...
misc Posted July 11, 2014 Author Share Posted July 11, 2014 I've attached a screenshot to illustrate the problem. Thanks for the effort. Link to comment Share on other sites More sharing options...
Oliver Morsch Posted July 11, 2014 Share Posted July 11, 2014 Read post #2 from Farshad ?! Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 11, 2014 Administrators Share Posted July 11, 2014 Unigui version? Link to comment Share on other sites More sharing options...
misc Posted July 11, 2014 Author Share Posted July 11, 2014 @ Farshad: uniGUI 0.95.0.1044 @ Oliver: sorry, can you rephrase? Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 11, 2014 Administrators Share Posted July 11, 2014 @ Farshad: uniGUI 0.95.0.1044 Can you prepare a test case? Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 11, 2014 Administrators Share Posted July 11, 2014 Another question: Will this problem persist if you don't handle OnException event at all? Link to comment Share on other sites More sharing options...
Oliver Morsch Posted July 11, 2014 Share Posted July 11, 2014 @ Oliver: sorry, can you rephrase? Farshad wrote in post #2: OnException event is only for non-visual code. ShowMessage() and etc. will not work here. ... I think ServerModule is another thread/context and something like ShowMessage() there will produce other problems. Link to comment Share on other sites More sharing options...
misc Posted July 14, 2014 Author Share Posted July 14, 2014 DelphiDeveloper helped me find the problem, which is also described here:http://www.sencha.com/forum/showthread.php?260320-4.2.0-Ext.suspendLayouts-causes-a-menu-to-be-not-rendered I used UniSession.AddJS('Ext.suspendLayouts()') in heavy control creation in order to eliminate unnecessary control painting, and in unhandled exceptions I dont reach UniSession.AddJS('Ext.resumeLayouts(true)'); So solved this, not an uniGUI bug, but the global exception problem stll persists: How do I create a global exception handler? I tried this, but it is not called at all: procedure TMainForm.UniFormCreate(Sender: TObject); begin Application.OnException:= AppException; end; procedure TMainForm.AppException(Sender: TObject; E: Exception); //not called! begin UniGUIDialogs.ShowMessage(E.Message); end; Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 16, 2014 Administrators Share Posted July 16, 2014 UniGUIServerModuleException() is the global exception handler. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted July 16, 2014 Administrators Share Posted July 16, 2014 Normally all exceptions are handled by framework and an alert is displayed. I checked the code and couldn't see why your message is not shown. Is it an ISAPI or standalone app? Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now