From: Pino Toscano Date: Wed, 29 May 2019 09:48:38 +0000 (+0200) Subject: Improve error reporting on init X-Git-Tag: v0.6~10 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=df5e926b5a1864d586e675845760ca31723458be;p=ocaml-augeas.git Improve error reporting on init Invoke aug_init with AUG_NO_ERR_CLOSE, so it is possible to provide a detailed Augeas.Error exception. --- 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)); }