From e74733627485950e31eb37c7af4badacbce7352f Mon Sep 17 00:00:00 2001 From: Michael Zronek Date: Wed, 27 Nov 2019 09:58:19 +0100 Subject: [PATCH] augeas: added lenspath to error message references #203 --- src/plugins/augeas/augeas.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 60d04139a05..6e0d8fbb23e 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -111,12 +111,17 @@ int elektraAugeasGenConf (KeySet * ks, Key * errorKey ELEKTRA_UNUSED) return retval; } -static const char * getAugeasError (augeas * augeasHandle) +static const char * getAugeasError (augeas * augeasHandle, const char * lensPath) { const char * reason = 0; if (aug_error (augeasHandle) != 0) { + const char * format = "%s\n\tlensPath: %s"; reason = aug_error_message (augeasHandle); + size_t messageSize = strlen (reason) + strlen (lensPath) + strlen (format); + char * buffer = elektraMalloc (messageSize); + snprintf (buffer, messageSize, format, reason, lensPath); + reason = buffer; } else { @@ -408,7 +413,7 @@ static int saveTree (augeas * augeasHandle, KeySet * ks, const char * lensPath, if (ret < 0) { /* report the augeas specific error */ - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (parentKey, getAugeasError (augeasHandle)); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (parentKey, getAugeasError (augeasHandle, lensPath)); } return ret; @@ -504,7 +509,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (ret < 0) { fclose (fh); - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle, lensPath)); errno = errnosave; return -1; } @@ -536,7 +541,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) { fclose (fh); ksDel (append); - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle, lensPath)); errno = errnosave; return -1; } @@ -590,7 +595,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) if (ret < 0) { fclose (fh); - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle)); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, getAugeasError (augeasHandle, lensPath)); errno = errnosave; return -1; }