chiark / gitweb /
bus: fix synthetic error messages
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Oct 2013 01:26:34 +0000 (03:26 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Oct 2013 01:29:20 +0000 (03:29 +0200)
src/libsystemd-bus/bus-message.c
src/libsystemd-bus/test-bus-chat.c

index 2cf1a7a..264a2f6 100644 (file)
@@ -682,7 +682,6 @@ fail:
         return r;
 }
 
-
 int bus_message_new_synthetic_error(
                 sd_bus *bus,
                 uint64_t serial,
@@ -712,6 +711,16 @@ int bus_message_new_synthetic_error(
                         goto fail;
         }
 
+        r = message_append_field_string(t, SD_BUS_MESSAGE_HEADER_ERROR_NAME, SD_BUS_TYPE_STRING, e->name, &t->error.name);
+        if (r < 0)
+                goto fail;
+
+        if (e->message) {
+                r = message_append_basic(t, SD_BUS_TYPE_STRING, e->message, (const void**) &t->error.message);
+                if (r < 0)
+                        goto fail;
+        }
+
         *m = t;
         return 0;
 
index f308edd..aefe8f1 100644 (file)
@@ -359,7 +359,7 @@ finish:
 static int quit_callback(sd_bus *b, sd_bus_message *m, void *userdata) {
         bool *x = userdata;
 
-        log_error("Quit callback: %s", strerror(bus_message_to_errno(m)));
+        log_error("Quit callback: %s", strerror(-bus_message_to_errno(m)));
 
         *x = 1;
         return 1;