MT#18333 eval around YAML::Tiny->read to handle implicit croak on error

Change-Id: Ia0aca819280154faf0360e630d44eb6f28317fe8
changes/70/4970/3
Kirill Solomko 10 years ago
parent 14dbc9d0b8
commit 370dd14f96

@ -602,9 +602,12 @@ sub do_pair_sync {
sub get_slave_hosts {
my $self = shift;
my $network = new YAML::Tiny;
$network = YAML::Tiny->read($NETWORK_YML) || do {
print "Can't read network file: $ERRNO\n";
my $network;
eval {
$network = YAML::Tiny->read($NETWORK_YML)
};
if ($@) {
print "Can't read network file: $EVAL_ERROR\n";
return;
};
my @hosts;
@ -708,9 +711,11 @@ sub do_slave_sync
}
sub main {
$yml = new YAML::Tiny;
$yml = YAML::Tiny->read($CONSTANTS_YML)
or die "Can't read constants file: $ERRNO\n";
my $yml;
eval {
$yml = YAML::Tiny->read($CONSTANTS_YML);
};
die "Can't read constants file: $EVAL_ERROR\n" if $EVAL_ERROR;
if ($init_passwords and not $test_mode and not -w $CONSTANTS_YML) {
die "$CONSTANTS_YML is not writable";

Loading…
Cancel
Save