From df5e926b5a1864d586e675845760ca31723458be Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 29 May 2019 11:48:38 +0200 Subject: [PATCH] Improve error reporting on init Invoke aug_init with AUG_NO_ERR_CLOSE, so it is possible to provide a detailed Augeas.Error exception. --- augeas-c.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/augeas-c.c b/augeas-c.c index 81f87f9..12ca51f 100644 --- a/augeas-c.c +++ b/augeas-c.c @@ -211,11 +211,16 @@ ocaml_augeas_create (value rootv, value loadpathv, value flagsv) flags |= flag_map[i]; } - t = aug_init (root, loadpath, flags); + /* Pass AUG_NO_ERR_CLOSE so we raise a detailed Augeas.Error. */ + t = aug_init (root, loadpath, flags | AUG_NO_ERR_CLOSE); if (t == NULL) raise_init_error ("Augeas.create"); + if (aug_error (t) != AUG_NOERROR) { + raise_error_and_maybe_close (t, "Augeas.init", true); + } + CAMLreturn (Val_augeas_t (t)); } -- 1.8.3.1