augeas: added lenspath to error message
references
@@ -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;
}
