1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-03 00:26:59 +02:00

Don't append strerror() to error message when errno is 0.

Some functions (e.g. getpwnam()/getgrnam()) will return an error but not set errno.  In this case there's no use in appending strerror(), which will be "Success".  This is confusing since an error has just been reported.

At least in the examples above, an error with no errno set just means "missing" and our current error message already conveys that.
This commit is contained in:
David Steele
2019-04-29 18:03:32 -04:00
parent 6ad44db9a0
commit 683b096e18
4 changed files with 43 additions and 4 deletions

View File

@ -269,6 +269,20 @@ testRun(void)
}
TRY_END();
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
{
errno = 0;
THROW_SYS_ERROR(AssertError, "message");
}
CATCH_ANY()
{
printf("%s\n", errorMessage());
assert(errorCode() == AssertError.code);
assert(strcmp(errorMessage(), "message") == 0);
}
TRY_END();
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
{
@ -282,6 +296,20 @@ testRun(void)
assert(strcmp(errorMessage(), "message 1: [5] Input/output error") == 0);
}
TRY_END();
// -------------------------------------------------------------------------------------------------------------------------
TRY_BEGIN()
{
errno = 0;
THROW_SYS_ERROR_FMT(AssertError, "message %d", 1);
}
CATCH_ANY()
{
printf("%s\n", errorMessage());
assert(errorCode() == AssertError.code);
assert(strcmp(errorMessage(), "message 1") == 0);
}
TRY_END();
}
// *****************************************************************************************************************************