Skip to content

Instantly share code, notes, and snippets.

@ptomato
Created September 10, 2013 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptomato/6516878 to your computer and use it in GitHub Desktop.
Save ptomato/6516878 to your computer and use it in GitHub Desktop.
Exceptions are treated differently depending on where they occur in GJS
const Gtk = imports.gi.Gtk;
Gtk.init(null);
let w = new Gtk.Window();
let b = new Gtk.Button({ label: "Click me for an exception" });
w.add(b);
b.connect('clicked', function() {
throw("This exception is not caught, only printed");
});
w.connect('destroy', Gtk.main_quit);
w.show_all();
try {
Gtk.main();
throw("This exception is caught");
} catch(e) {
print("The exception I caught was this:", e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment