mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Rename error-handling variables in Main.pm to conform to standard.
This commit is contained in:
parent
fa53e2eddb
commit
d3cfeebdf9
@ -64,6 +64,10 @@
|
||||
<release-item>
|
||||
<p>Show exact log level required for stack trace param output instead of just <quote>debug</quote>.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Rename error-handling variables in <code>Main.pm</code> to conform to standard.</p>
|
||||
</release-item>
|
||||
</release-development-list>
|
||||
</release-core-list>
|
||||
|
||||
|
@ -43,8 +43,8 @@ sub main
|
||||
|
||||
# Run in eval block to catch errors
|
||||
# ------------------------------------------------------------------------------------------------------------------------------
|
||||
my $result = 0;
|
||||
my $message = '';
|
||||
my $iResult = 0;
|
||||
my $strMessage = '';
|
||||
|
||||
eval
|
||||
{
|
||||
@ -86,7 +86,7 @@ sub main
|
||||
require pgBackRest::Archive::Get::Get;
|
||||
pgBackRest::Archive::Get::Get->import();
|
||||
|
||||
$result = new pgBackRest::Archive::Get::Get()->process(\@stryCommandArg);
|
||||
$iResult = new pgBackRest::Archive::Get::Get()->process(\@stryCommandArg);
|
||||
}
|
||||
|
||||
# Process remote command
|
||||
@ -145,7 +145,7 @@ sub main
|
||||
require pgBackRest::Check::Check;
|
||||
pgBackRest::Check::Check->import();
|
||||
|
||||
$result = new pgBackRest::Check::Check()->process();
|
||||
$iResult = new pgBackRest::Check::Check()->process();
|
||||
}
|
||||
|
||||
# Process start/stop commands
|
||||
@ -239,7 +239,7 @@ sub main
|
||||
require pgBackRest::Stanza;
|
||||
pgBackRest::Stanza->import();
|
||||
|
||||
$result = new pgBackRest::Stanza()->process();
|
||||
$iResult = new pgBackRest::Stanza()->process();
|
||||
}
|
||||
|
||||
# Process backup command
|
||||
@ -282,26 +282,26 @@ sub main
|
||||
# If a backrest exception
|
||||
if (isException(\$oException))
|
||||
{
|
||||
$result = $oException->code();
|
||||
$iResult = $oException->code();
|
||||
|
||||
# Only return message if we are in an async process since this will not be logged to the console
|
||||
if (!$bConfigLoaded && cfgOption(CFGOPT_ARCHIVE_ASYNC))
|
||||
{
|
||||
$message = $oException->message();
|
||||
$strMessage = $oException->message();
|
||||
}
|
||||
}
|
||||
# Else a regular Perl exception
|
||||
else
|
||||
{
|
||||
$result = ERROR_UNHANDLED;
|
||||
$message =
|
||||
$iResult = ERROR_UNHANDLED;
|
||||
$strMessage =
|
||||
'process terminated due to an unhandled exception' .
|
||||
(defined($oException) ? ":\n${oException}" : ': [exception not defined]');
|
||||
}
|
||||
};
|
||||
|
||||
# Return result and error message if the result is an error
|
||||
return $result, $message;
|
||||
return $iResult, $strMessage;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
|
@ -13297,8 +13297,8 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"my $result = 0;\n"
|
||||
"my $message = '';\n"
|
||||
"my $iResult = 0;\n"
|
||||
"my $strMessage = '';\n"
|
||||
"\n"
|
||||
"eval\n"
|
||||
"{\n"
|
||||
@ -13340,7 +13340,7 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"require pgBackRest::Archive::Get::Get;\n"
|
||||
"pgBackRest::Archive::Get::Get->import();\n"
|
||||
"\n"
|
||||
"$result = new pgBackRest::Archive::Get::Get()->process(\\@stryCommandArg);\n"
|
||||
"$iResult = new pgBackRest::Archive::Get::Get()->process(\\@stryCommandArg);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
@ -13399,7 +13399,7 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"require pgBackRest::Check::Check;\n"
|
||||
"pgBackRest::Check::Check->import();\n"
|
||||
"\n"
|
||||
"$result = new pgBackRest::Check::Check()->process();\n"
|
||||
"$iResult = new pgBackRest::Check::Check()->process();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
@ -13493,7 +13493,7 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"require pgBackRest::Stanza;\n"
|
||||
"pgBackRest::Stanza->import();\n"
|
||||
"\n"
|
||||
"$result = new pgBackRest::Stanza()->process();\n"
|
||||
"$iResult = new pgBackRest::Stanza()->process();\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
@ -13536,26 +13536,26 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"\n"
|
||||
"if (isException(\\$oException))\n"
|
||||
"{\n"
|
||||
"$result = $oException->code();\n"
|
||||
"$iResult = $oException->code();\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"if (!$bConfigLoaded && cfgOption(CFGOPT_ARCHIVE_ASYNC))\n"
|
||||
"{\n"
|
||||
"$message = $oException->message();\n"
|
||||
"$strMessage = $oException->message();\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"else\n"
|
||||
"{\n"
|
||||
"$result = ERROR_UNHANDLED;\n"
|
||||
"$message =\n"
|
||||
"$iResult = ERROR_UNHANDLED;\n"
|
||||
"$strMessage =\n"
|
||||
"'process terminated due to an unhandled exception' .\n"
|
||||
"(defined($oException) ? \":\\n${oException}\" : ': [exception not defined]');\n"
|
||||
"}\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"return $result, $message;\n"
|
||||
"return $iResult, $strMessage;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
|
@ -67,7 +67,7 @@ perlMain()
|
||||
|
||||
// Construct Perl main call
|
||||
String *mainCall = strNewFmt(
|
||||
"($result, $message) = " PGBACKREST_MAIN "('%s'%s)", cfgCommandName(cfgCommand()), strPtr(commandParam));
|
||||
"($iResult, $strMessage) = " PGBACKREST_MAIN "('%s'%s)", cfgCommandName(cfgCommand()), strPtr(commandParam));
|
||||
|
||||
FUNCTION_TEST_RESULT(STRING, mainCall);
|
||||
}
|
||||
@ -220,8 +220,8 @@ perlExec()
|
||||
perlEval(perlMain());
|
||||
|
||||
// Return result code
|
||||
int code = (int)SvIV(get_sv("result", 0));
|
||||
char *message = SvPV_nolen(get_sv("message", 0)); // {uncovered - internal Perl macro branch}
|
||||
int code = (int)SvIV(get_sv("iResult", 0));
|
||||
char *message = SvPV_nolen(get_sv("strMessage", 0)); // {uncoverable - internal Perl macro branch}
|
||||
|
||||
if (code >= errorTypeCode(&AssertError)) // {uncovered - success tested in integration}
|
||||
THROW_CODE(code, strlen(message) == 0 ? PERL_EMBED_ERROR : message); // {+uncovered}
|
||||
|
@ -20,7 +20,7 @@ testRun()
|
||||
cfgCommandSet(cfgCmdInfo);
|
||||
cfgExeSet(strNew("/path/to/pgbackrest"));
|
||||
|
||||
TEST_RESULT_STR(strPtr(perlMain()), "($result, $message) = pgBackRest::Main::main('info')", "command with no options");
|
||||
TEST_RESULT_STR(strPtr(perlMain()), "($iResult, $strMessage) = pgBackRest::Main::main('info')", "command with no options");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
cfgOptionValidSet(cfgOptCompress, true);
|
||||
@ -32,7 +32,7 @@ testRun()
|
||||
cfgCommandParamSet(commandParamList);
|
||||
|
||||
TEST_RESULT_STR(
|
||||
strPtr(perlMain()), "($result, $message) = pgBackRest::Main::main('info','A','B')",
|
||||
strPtr(perlMain()), "($iResult, $strMessage) = pgBackRest::Main::main('info','A','B')",
|
||||
"command with one option and params");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user