require 'gtk2' module GLib module_function def exit_application(exception, status) raise end end w = Gtk::Window.new b = Gtk::Button.new("Raise error") w << b w.show_all b.signal_connect("clicked") do |button| 1/0 end begin Gtk.main rescue Exception => e puts "## Rescuing exception" puts e.backtrace puts e.message puts "## Exiting" end