mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-26 20:52:37 +01:00
Plugins/Plang: fix error handling
This commit is contained in:
parent
747cb24392
commit
a337903787
2
Plang
2
Plang
@ -1 +1 @@
|
||||
Subproject commit 41c7c3c5c801f7b440a8c90502c77777585d7274
|
||||
Subproject commit 6fb7dd9fbad69819c684f6a60f88b62ca867506b
|
@ -84,15 +84,18 @@ sub cmd_plang {
|
||||
return $usage if not length $context->{arguments};
|
||||
|
||||
$self->{output} = ""; # collect output of the embedded Plang program
|
||||
my $result = $self->{plang}->interpret_string($context->{arguments});
|
||||
|
||||
# check to see if we need to append final result to output
|
||||
if (defined $result->[1]) {
|
||||
if ($result->[0] eq 'STRING') {
|
||||
$self->{output} .= $self->{plang}->{interpreter}->output_string_literal($result->[1]);
|
||||
} else {
|
||||
$self->{output} .= $self->{plang}->{interpreter}->output_value($result);
|
||||
eval {
|
||||
my $result = $self->{plang}->interpret_string($context->{arguments});
|
||||
|
||||
# check to see if we need to append final result to output
|
||||
if (defined $result->[1]) {
|
||||
$self->{output} .= $self->{plang}->{interpreter}->output_value($result, literal => 1);
|
||||
}
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
$self->{output} .= $@;
|
||||
}
|
||||
|
||||
# return the output
|
||||
@ -106,10 +109,17 @@ sub cmd_plangrepl {
|
||||
return $usage if not length $context->{arguments};
|
||||
|
||||
$self->{output} = ""; # collect output of the embedded Plang program
|
||||
my $result = $self->{plang}->interpret_string($context->{arguments}, repl => 1);
|
||||
|
||||
# check to see if we need to append final result to output
|
||||
$self->{output} .= $self->{plang}->{interpreter}->output_value($result, repl => 1) if defined $result->[1];
|
||||
eval {
|
||||
my $result = $self->{plang}->interpret_string($context->{arguments}, repl => 1);
|
||||
|
||||
# check to see if we need to append final result to output
|
||||
$self->{output} .= $self->{plang}->{interpreter}->output_value($result, repl => 1) if defined $result->[1];
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
$self->{output} .= $@;
|
||||
}
|
||||
|
||||
# return the output
|
||||
return length $self->{output} ? $self->{output} : "No output.";
|
||||
|
Loading…
Reference in New Issue
Block a user