5
0
mirror of git://git.proxmox.com/git/pve-guest-common.git synced 2024-12-22 13:34:00 +03:00

follouwp: saner exception handling

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-02-01 10:08:07 +01:00
parent 3acb4e7463
commit 1c9da8ac5b

View File

@ -46,27 +46,17 @@ sub exec_hookscript {
my ($conf, $vmid, $phase, $stop_on_error) = @_;
return if !$conf->{hookscript};
my $hookscript = eval { check_hookscript($conf->{hookscript}) };
if (my $err = $@) {
if ($stop_on_error) {
die $err;
} else {
warn $err;
return;
}
}
eval {
my $hookscript = check_hookscript($conf->{hookscript});
die $@ if $@;
PVE::Tools::run_command([$hookscript, $vmid, $phase]);
};
if (my $err = $@) {
my $errmsg = "hookscript error for $vmid on $phase: $err\n";
if ($stop_on_error) {
die $errmsg;
} else {
warn $errmsg;
}
die $errmsg if ($stop_on_error);
warn $errmsg;
}
}