1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Error when specified vm is invalid.

This commit is contained in:
David Steele 2019-10-17 14:00:18 +02:00
parent a52faf83a5
commit e06db21e35
2 changed files with 26 additions and 1 deletions

View File

@ -13,6 +13,7 @@ use Carp qw(confess);
use Exporter qw(import);
our @EXPORT = qw();
use pgBackRest::Common::Exception;
use pgBackRest::Common::Log;
use pgBackRest::DbVersion;
@ -496,6 +497,21 @@ foreach my $strPgVersion (versionSupport())
}
}
####################################################################################################################################
# vmValid
####################################################################################################################################
sub vmValid
{
my $strVm = shift;
if (!defined($oyVm->{$strVm}))
{
confess &log(ERROR, "no definition for vm '${strVm}'", ERROR_OPTION_INVALID_VALUE);
}
}
push @EXPORT, qw(vmValid);
####################################################################################################################################
# vmGet
####################################################################################################################################

View File

@ -356,6 +356,11 @@ eval
{
$strVm = VM_ALL;
}
# Else make sure vm is valid
elsif ($strVm ne VM_ALL)
{
vmValid($strVm);
}
# Get the base backrest path
my $strBackRestBase = dirname(dirname(abs_path($0)));
@ -1547,7 +1552,11 @@ or do
# If a backrest exception then return the code
if (isException(\$EVAL_ERROR))
{
syswrite(*STDOUT, $EVAL_ERROR->message() . "\n" . $EVAL_ERROR->trace());
if ($EVAL_ERROR->code() != ERROR_OPTION_INVALID_VALUE)
{
syswrite(*STDOUT, $EVAL_ERROR->message() . "\n" . $EVAL_ERROR->trace());
}
exit $EVAL_ERROR->code();
}