mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-30 05:39:12 +02:00
Improve working directory error message.
Improve the wording of the error message and add a hint to make it clearer what is wrong and how the user can fix it. Also change the assert to a regular error since this is not an internal error.
This commit is contained in:
parent
dac182c06e
commit
fc77c51182
@ -15,6 +15,15 @@
|
||||
<release date="XXXX-XX-XX" version="2.30dev" title="UNDER DEVELOPMENT">
|
||||
<release-core-list>
|
||||
<release-improvement-list>
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-contributor id="david.steele"/>
|
||||
<release-item-reviewer id="stefan.fercot"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Improve working directory error message.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-contributor id="david.christensen"/>
|
||||
|
@ -352,10 +352,16 @@ walPath(const String *walFile, const String *pgPath, const String *command)
|
||||
char newWorkDir[4096];
|
||||
THROW_ON_SYS_ERROR(getcwd(newWorkDir, sizeof(newWorkDir)) == NULL, FormatError, "unable to get cwd");
|
||||
|
||||
// Error if the new working directory is not equal to the original current working directory. This means that
|
||||
// PostgreSQL and pgBackrest have a different idea about where the PostgreSQL data directory is located.
|
||||
// Error if the new working directory is not equal to the original current working directory. This means that PostgreSQL
|
||||
// and pgBackrest have a different idea about where the PostgreSQL data directory is located.
|
||||
if (strcmp(currentWorkDir, newWorkDir) != 0)
|
||||
THROW_FMT(AssertError, "working path '%s' is not the same path as '%s'", currentWorkDir, strZ(pgPath));
|
||||
{
|
||||
THROW_FMT(
|
||||
OptionInvalidValueError,
|
||||
PG_NAME " working directory '%s' is not the same as option " CFGOPT_PG1_PATH " '%s'\n"
|
||||
"HINT: is the " PG_NAME " data_directory configured the same as the " CFGOPT_PG1_PATH " option?",
|
||||
currentWorkDir, strZ(pgPath));
|
||||
}
|
||||
}
|
||||
|
||||
result = strNewFmt("%s/%s", strZ(pgPath), strZ(walFile));
|
||||
|
@ -208,8 +208,10 @@ testRun(void)
|
||||
|
||||
THROW_ON_SYS_ERROR(chdir("/") != 0, PathMissingError, "unable to chdir()");
|
||||
TEST_ERROR(
|
||||
walPath(strNew("relative/path"), pgPathLink, strNew("test")), AssertError,
|
||||
hrnReplaceKey("working path '/' is not the same path as '{[path]}/pg-link'"));
|
||||
walPath(strNew("relative/path"), pgPathLink, strNew("test")), OptionInvalidValueError,
|
||||
hrnReplaceKey(
|
||||
"PostgreSQL working directory '/' is not the same as option pg1-path '{[path]}/pg-link'\n"
|
||||
"HINT: is the PostgreSQL data_directory configured the same as the pg1-path option?"));
|
||||
|
||||
TEST_ERROR(
|
||||
walPath(strNew("relative/path"), NULL, strNew("test")), OptionRequiredError,
|
||||
|
Loading…
x
Reference in New Issue
Block a user