From: Emmanuel T. <emm...@wa...> - 2003-07-23 13:13:58
|
> Emmanuel Touzery wrote: > > > I'm having the problem that my GUI app might have some bugs; in that > > case, instead of seeing it exiting violently, dumping the stack on the > > command line (which will never be seen by the user in most cases), i would > > like to catch the exception and display a nice dialog box. > > Wrapping the app.run call (i don't remember how it's called, but it's > > something like that) in a begin/rescue block doesn't seem to catch this > > exception. > > Is it a standard Ruby exception, or is the Ruby interpreter (ruby) > seg-faulting? If it's the former (a regular exception), it /should/ be > raised all the way to the "top" and get caught in your begin-rescue > block around the call to FXApp#run. standard exception. for an interpreter crash there is not much to display anyway ;O) i want a backtrace so that i can debug. i'm happy to read that FXApp#run is going to "forward me" the exception. but it doesn't seem to work here (see code snippet at the end of the mail). > This sounds way too complicated, IMO. If wrapping the call to FXApp#run > with a "last-chance" begin-rescue block is failing to catch exceptions, > I would like to see that demonstrated and get it fixed. I think the best > solution is to get a good group of testers and get them to help you find > the bugs ;) maybe i'm doing something wrong, but how about this code: click on file->open #!/usr/bin/env ruby require 'fox' include Fox class GlossaryMainWindow < FXMainWindow include Responder ID_OPEN, ID_LAST = enum(FXMainWindow::ID_LAST, 2) def initialize(app) # Initialize base class first super(app, "Glossary", nil, nil, DECOR_ALL, 0, 0, 400, 300) FXMAPFUNC(SEL_COMMAND, ID_OPEN, :onCmdOpen) # Make main window; set myself as the target # setTarget(self) # setSelector(ID_TITLE) # Make menu bar dragshell1 = FXToolbarShell.new(self, FRAME_RAISED|FRAME_THICK) menubar = FXMenubar.new(self, dragshell1, LAYOUT_SIDE_TOP|LAYOUT_FILL_X) FXToolbarGrip.new(menubar, menubar, FXMenubar::ID_TOOLBARGRIP, TOOLBARGRIP_SINGLE) # File menu filemenu = FXMenuPane.new(self) FXMenuTitle.new(menubar, "&File", nil, filemenu) # File Menu entries FXMenuCommand.new(filemenu, "&Open... \tCtl-O\tOpen document file.", @openicon, self, ID_OPEN) end def onCmdOpen(sender, sel, ptr) pouf # <-- invalid code end # Create and show the main window def create super show(PLACEMENT_SCREEN) end end if $0 == __FILE__ # Construct an application application = FXApp.new('Glossary', 'Emmanuel') # Construct the main window GlossaryMainWindow.new(application) # Create and show the application windows application.create # Run the application begin application.run rescue FXMessageBox.error(self, MBOX_OK, "Error", "Boom!") end end |