3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

Refresher: improve error handling

This commit is contained in:
Pragmatic Software 2020-02-16 09:51:59 -08:00
parent 08c1a539de
commit 394fc4d083

View File

@ -25,14 +25,25 @@ sub initialize {
sub refresh {
my ($self, $from, $nick, $user, $host, $arguments) = @_;
my $refresh_error;
local $SIG{__WARN__} = sub {
$refresh_error = shift;
return if $refresh_error =~ /Can't undef active/;
return if $refresh_error =~ /Subroutine \w+ redefined/;
$refresh_error =~ s/\s+Compilation failed in require at \/usr.*//;
$self->{pbot}->{logger}->log("Error refreshing: $refresh_error\n");
};
my $result = eval {
if (not $arguments) {
$self->{pbot}->{logger}->log("Refreshing all modified modules\n");
$self->{refresher}->refresh;
return "Error refreshing: $refresh_error" if defined $refresh_error;
return "Refreshed all modified modules.\n";
} else {
$self->{pbot}->{logger}->log("Refreshing module $arguments\n");
$self->{refresher}->refresh_module($arguments);
return "Error refreshing: $refresh_error" if defined $refresh_error;
$self->{pbot}->{logger}->log("Refreshed module.\n");
return "Refreshed module.\n";
}