http://bugzilla.moblin.org/show_bug.cgi?id=6548
--- Comment #8 from yongsheng zhu <yongsheng.zhu(a)intel.com> 2009-11-10 01:33:12 PST
---
(In reply to comment #7)
(In reply to comment #6)
> There are still many exceptions needed to throw
> new exceptions instead of 'runtime_error'.
> Should be fixed in future.
Are you suggesting that all exceptions ever thrown in SyncEvolution should be
derived from DBusSyncException? That would again introduce an unwanted
dependency, now in the core code.
Yes, you are right.
How about this approach:
In gdbus-cxx-bridge.h:
static DBusMessage *handleException(DBusMessage *msg)
{
try {
#ifdef DBUS_CXX_EXCEPTION_HANDLER
return DBUS_CXX_EXCEPTION_HANDLER(msg);
#else
throw;
#endif
} catch (const std::runtime_error &ex) {
return g_dbus_create_error(msg,
"org.syncevolution.gdbus-cxx.Exception", "%s", ex.what());
} catch (...) {
return g_dbus_create_error(msg,
"org.syncevolution.gdbus-cxx.Exception", "unknown");
}
}
In syncevo-dbus-server.cpp:
static DBusMessage *SyncEvoHandleException(DBusMessage *msg);
#define DBUS_CXX_EXCEPTION_HANDLER SyncEvoHandleException
#include <gdbus-cxx-bridge.h>
...
static DBusMessage *SyncEvoHandleException(DBusMessage *msg);
{
Exception::handle(); // for logging
try {
throw;
} catch const DBusCXXException &ex) {
return g_dbus_create_error(msg, ex.getName().c_str(), "%s",
ex.getMessage());
} catch } catch (const std::runtime_error &ex) {
return g_dbus_create_error(msg, "org.syncevolution.Exception",
"%s",
ex.what());
} catch (...) {
return g_dbus_create_error(msg, "org.syncevolution.Exception",
"unknown");
}
}
workable. Glib also uses this method heavily.
--
Configure bugmail:
http://bugzilla.moblin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching someone on the CC list of the bug.