[augeas-devel] augeas: master - * src/augparse.c: get error details from error API

David Lutterkort lutter at fedoraproject.org
Thu Oct 1 00:24:04 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=f1ef951acce6537efdbc3e41ceee48951981f928
Commit:        f1ef951acce6537efdbc3e41ceee48951981f928
Parent:        c006538412b3692b3fc63cf144f5fcc90659121c
Author:        David Lutterkort <lutter at redhat.com>
AuthorDate:    Wed Sep 30 17:06:51 2009 -0700
Committer:     David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Sep 30 17:20:39 2009 -0700

* src/augparse.c: get error details from error API

---
 src/augparse.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/augparse.c b/src/augparse.c
index 630af52..0fd5c84 100644
--- a/src/augparse.c
+++ b/src/augparse.c
@@ -116,6 +116,10 @@ int main(int argc, char **argv) {
 
     argz_stringify(loadpath, loadpathlen, PATH_SEP_CHAR);
     aug = aug_init(NULL, loadpath, flags);
+    if (aug == NULL) {
+        fprintf(stderr, "Memory exhausted\n");
+        return 2;
+    }
 
     if (print_version) {
         print_version_info(aug);
@@ -123,9 +127,14 @@ int main(int argc, char **argv) {
     }
 
     if (__aug_load_module_file(aug, argv[optind]) == -1) {
-        fprintf(stderr, "%s: error: Loading failed\n", argv[optind]);
+        fprintf(stderr, "%s\n", aug_error_message(aug));
+        const char *s = aug_error_details(aug);
+        if (s != NULL) {
+            fprintf(stderr, "%s\n", s);
+        }
         exit(EXIT_FAILURE);
     }
+
     aug_close(aug);
     free(loadpath);
 }




More information about the augeas-devel mailing list