1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-18 04:58:51 +02:00

Add JSON error when value does not parse in Ini object.

If the JSON value fails to parse it is helpful to have the error message, at least for debugging.
This commit is contained in:
David Steele 2022-04-20 19:49:23 -04:00
parent da6b4abc58
commit cb7a5f1ef3
2 changed files with 7 additions and 2 deletions

View File

@ -408,7 +408,11 @@ iniLoad(
lineEqual = strstr(lineEqual + 1, "=");
if (lineEqual == NULL)
THROW_FMT(FormatError, "invalid JSON value at line %u: %s", lineIdx + 1, linePtr);
{
THROW_FMT(
FormatError, "invalid JSON value at line %u '%s': %s", lineIdx + 1, linePtr,
errorMessage());
}
// Try again with = in new position
retry = true;

View File

@ -49,7 +49,8 @@ testRun(void)
iniBuf = BUFSTRZ("[section]\nkey=value\n");
TEST_ERROR(
iniLoad(ioBufferReadNew(iniBuf), testIniLoadCallback, result), FormatError, "invalid JSON value at line 2: key=value");
iniLoad(ioBufferReadNew(iniBuf), testIniLoadCallback, result), FormatError,
"invalid JSON value at line 2 'key=value': invalid type at 'value'");
// Key outside of section
// -------------------------------------------------------------------------------------------------------------------------