The current code was broken, as the field 1 of the exception value is the error code (int), not an error string, and thus it would have crashed. This did not happen in practice, as all the usage of ocaml-augeas were only in the inspection code with ad-hoc exception catching blocks. Other than fixing the aforementioned issue, enhance the error reporting to be as close as possible to what the current AUGEAS_ERROR() macro does: error message, error minor message (if available), error details (if available). --- daemon/daemon-c.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/daemon/daemon-c.c b/daemon/daemon-c.c index 533bf7ce7..62e7daf2c 100644 --- a/daemon/daemon-c.c +++ b/daemon/daemon-c.c @@ -65,8 +65,15 @@ guestfs_int_daemon_exn_to_reply_with_error (const char *func, value exn) reply_with_error ("%s", String_val (Field (exn, 1))); else if (STREQ (exn_name, "Invalid_argument")) reply_with_error ("invalid argument: %s", String_val (Field (exn, 1))); - else if (STREQ (exn_name, "Augeas.Error")) - reply_with_error ("augeas error: %s", String_val (Field (exn, 1))); + else if (STREQ (exn_name, "Augeas.Error")) { + const char *message = String_val (Field (exn, 3)); + const char *minor = String_val (Field (exn, 4)); + const char *details = String_val (Field (exn, 5)); + reply_with_error ("augeas error: %s%s%s%s%s", + message, + minor ? ": " : "", minor ? minor : "", + details ? ": " : "", details ? details : ""); +} else if (STREQ (exn_name, "PCRE.Error")) { value pair = Field (exn, 1); reply_with_error ("PCRE error: %s (PCRE error code: %d)", -- 2.21.0