From: Michael Witrant Date: 2001-09-22T22:11:34+09:00 Subject: [ruby-talk:21530] Win32: rubyw.exe and exceptions in a message box Hello, Since rubyw.exe cannot output anything (no console), fixing unhandled exception is boring. It would help if it displayed unhandled exceptions in a native Windows message box. I wrote a small ebox.rb script (see below) and replaced the .rbw association to "c:\ruby\bin\rubyw.exe" "C:\ruby\lib\ruby\site_ruby\1.6\ebox.rb" "%1" %* It now displays a message box on error, even parse errors. Do you think it should be the default behavior of rubyw.exe? Can it break anything in the executed script? Does it work on any win32 version? I'm using Win98. Mike. midulo. ------- # ebox.rb: Run ARGV.shift and print exception in a Windows MessageBox if it occurs. begin script = ARGV.shift raise ArgumentError, "usage: #$0 " if script.nil? $0 = script load script rescue Exception => e require 'Win32API' message_box = Win32API.new("user32", "MessageBox", ['i','p','p','i'], 'i') icon_error = 0x00000010 message = "An error occured while running #$0:\n" message << "#{e.message} (#{e.class}) in:\n" message << e.backtrace.join("\n") message_box.call(0, message, "Ruby: Unhandled exception", icon_error) end