0

below is the code which is called by the gtk closing action -->

def on_main_window_destroy(object)
  begin
  $client.send(':exit')
  Thread.kill $client.response
  rescue
    puts 'exiting'
  end
  Thread.kill $receiving_message
  Gtk.main_quit()
  exit
end

which results in this output.

app.rb:81:in `exit': exit
 from app.rb:81:in `on_main_window_destroy'
 from /home/user/.gem/ruby/2.4.0/gems/gobject-introspection-3.1.8/lib/gobject-introspection/loader.rb:110:in `invoke'
 from /home/user/.gem/ruby/2.4.0/gems/gobject-introspection-3.1.8/lib/gobject-introspection/loader.rb:110:in `block in define_singleton_method'
 from app.rb:97:in `<main>'

the program works fine .. and it doesn't create a mess for me .. but i want to know the reasons for these errors so that i can handle it.

1 Answers1

1

The Kernel#exit raises an exception to terminate the program, that looks like be the exception message you're asking about:

Initiates the termination of the Ruby script by raising the SystemExit exception. This exception may be caught.

As for the "block in define_singleton_method" part of the stack trace, while ruby has a define_singleton_method, if you look at line 110 of that file specified, you'll see that the method you are in is also called define_singleton_method and you are inside a block in that method:

def define_singleton_method(klass, name, info)
  # ... 
  singleton_class.__send__(:define_method, name) do |*arguments, &block|
    arguments, block = prepare.call(arguments, &block) # <<< Line 110
    # ...
  end
end

I'm not sure why you're actually seeing that output instead of just exiting silently like you normally would, a possibility is that somewhere in the code, something is just rescuing the base Exception, instead of StandardError, which is generally a bad idea, though they may be just logging/outputting and re-raising it (which as seen in some of those answers, is OK), it's all just speculation without digging around a lot further into the code (it might not even be in this gem)

Simple Lime
  • 10,790
  • 2
  • 17
  • 32