Move DBusException and wrapErrors to separate module

Also improved its implemention.
This prepares for new exception types to be added in later commits.
This commit is contained in:
Harry T. Vennik 2017-07-08 15:56:31 +02:00
parent 8410fc21a8
commit 12b3b61c1b
2 changed files with 39 additions and 17 deletions

View file

@ -12,23 +12,8 @@ import std.conv;
import std.range;
import std.algorithm;
class DBusException : Exception {
this(DBusError *err) {
super(err.message.fromStringz().idup);
}
}
T wrapErrors(T)(T delegate(DBusError *err) del) {
DBusError error;
dbus_error_init(&error);
T ret = del(&error);
if(dbus_error_is_set(&error)) {
auto ex = new DBusException(&error);
dbus_error_free(&error);
throw ex;
}
return ret;
}
// This import is public for backwards compatibility
public import ddbus.exception : wrapErrors, DBusException;
struct ObjectPath {
private string _value;