mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 10:59:29 +01:00
Refresher: improve error handling
This commit is contained in:
parent
08c1a539de
commit
394fc4d083
@ -25,14 +25,25 @@ sub initialize {
|
|||||||
|
|
||||||
sub refresh {
|
sub refresh {
|
||||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
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 {
|
my $result = eval {
|
||||||
if (not $arguments) {
|
if (not $arguments) {
|
||||||
$self->{pbot}->{logger}->log("Refreshing all modified modules\n");
|
$self->{pbot}->{logger}->log("Refreshing all modified modules\n");
|
||||||
$self->{refresher}->refresh;
|
$self->{refresher}->refresh;
|
||||||
|
return "Error refreshing: $refresh_error" if defined $refresh_error;
|
||||||
return "Refreshed all modified modules.\n";
|
return "Refreshed all modified modules.\n";
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{logger}->log("Refreshing module $arguments\n");
|
$self->{pbot}->{logger}->log("Refreshing module $arguments\n");
|
||||||
$self->{refresher}->refresh_module($arguments);
|
$self->{refresher}->refresh_module($arguments);
|
||||||
|
return "Error refreshing: $refresh_error" if defined $refresh_error;
|
||||||
$self->{pbot}->{logger}->log("Refreshed module.\n");
|
$self->{pbot}->{logger}->log("Refreshed module.\n");
|
||||||
return "Refreshed module.\n";
|
return "Refreshed module.\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user