Ejemplo n.º 1
0
static void exception_handler() {
    try {
	throw; // re-throw current exception
    } catch (const GxFatalError& error) {
	cerr << error.what() << endl;
	gx_print_fatal(_("Guitarix fatal error"), error.what());
    } catch (const Glib::OptionError &error) {
	cerr << error.what() << endl;
	cerr << _("use \"guitarix -h\" to get a help text") << endl;
	gx_print_fatal(_("Guitarix Commandline Option Error"),
		       Glib::ustring::compose(
			   "%1\n%2",
			   error.what(),
			   _("use \"guitarix -h\" to get a help text")));
    } catch (const Glib::Error& error) {
	const GError *perr = error.gobj();
	Glib::ustring msg = Glib::ustring::compose(
	    "Glib::Error[%1/%2]: %3",
	    g_quark_to_string(perr->domain),
	    perr->code,
	    (perr->message) ? perr->message : "(null)");
	cerr << msg << endl;
	gx_print_fatal(_("Guitarix fatal error"), msg);
    } catch (const std::exception& except) {
	Glib::ustring msg = Glib::ustring::compose(
	    "std::exception: %1", except.what());
	cerr << msg << endl;
	gx_print_fatal(_("Guitarix fatal error"), msg);
    } catch(...) {
	cerr << _("unknown error") << endl;
	gx_print_fatal(_("Guitarix fatal error"),_("unknown error"));
    }
}
Ejemplo n.º 2
0
AvahiBrowser::AvahiBrowser()
    : client(0),
      browser(0),
      resolver(0),
      services(),
      service_names(),
      changed(),
      cache_done(false),
      found_name(),
      found_host() {
    client = ga_client_new(GaClientFlags(0));
    GError *error = 0;
    if (!ga_client_start(client, &error)) {
	gx_print_fatal(
	    _("Avahi system error"),
	    Glib::ustring::compose(
		_("%1\n\nuse command line arguments --rpchost and/or"
		  " --rpcport to connect directly"), error->message));
    }
    browser = ga_service_browser_new("_guitarix._tcp");
    ga_service_browser_attach(browser, client, &error);
    g_signal_connect(browser, "new-service", G_CALLBACK(new_service), this);
    g_signal_connect(browser, "removed-service", G_CALLBACK(removed_service), this);
    g_signal_connect(browser, "cache-exhausted", G_CALLBACK(cache_exhausted), this);
}