diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-05-29 01:34:06 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-05-29 01:34:06 -0500 |
commit | 1ce2f2c8f0c44f345fe83a43de91fc094e5a8260 (patch) | |
tree | 7188b1de783c5c175eba0080b95ff5eecc64f51b /lib/App/REPL.pm | |
parent | 3b4c8e20ecc690836ff7f7ea7889bbcd43b3d3e8 (diff) | |
download | reply-1ce2f2c8f0c44f345fe83a43de91fc094e5a8260.tar.gz reply-1ce2f2c8f0c44f345fe83a43de91fc094e5a8260.zip |
handle exceptions
Diffstat (limited to 'lib/App/REPL.pm')
-rw-r--r-- | lib/App/REPL.pm | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/App/REPL.pm b/lib/App/REPL.pm index 6f74385..4c8110a 100644 --- a/lib/App/REPL.pm +++ b/lib/App/REPL.pm @@ -45,7 +45,12 @@ sub run { while (defined(my $line = $self->_read)) { my @result = $self->_eval($line); - $self->_print(@result); + if ($@) { + $self->_print_error($@); + } + else { + $self->_print_result(@result); + } } print "\n"; } @@ -67,7 +72,15 @@ sub _eval { return $self->_wrapped_plugin('evaluate', $line); } -sub _print { +sub _print_error { + my $self = shift; + my ($error) = @_; + + ($error) = $self->_chained_plugin('munge_error', $error); + $self->_wrapped_plugin('print_error', $error); +} + +sub _print_result { my $self = shift; my (@result) = @_; |