Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
augeas: added lenspath to error message
Browse files Browse the repository at this point in the history
references #203
  • Loading branch information
Michael Zronek committed Nov 27, 2019
1 parent 1ec9a77 commit e747336
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/plugins/augeas/augeas.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e747336

Please sign in to comment.