summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-10-31 14:10:03 -0500
committerJesse Luehrs <doy@tozt.net>2009-10-31 14:10:03 -0500
commite9f62695a8925e0ebb74dba5d6b14c6c84ffef03 (patch)
treed2758f0e2a166aa0aaba49860300f91a22c4db9e
parent6a3e808ef1cbc34a586c88b56851223fa1bf4786 (diff)
downloadim-engine-plugin-commands-e9f62695a8925e0ebb74dba5d6b14c6c84ffef03.tar.gz
im-engine-plugin-commands-e9f62695a8925e0ebb74dba5d6b14c6c84ffef03.zip
use try/catch rather than eval
-rw-r--r--lib/IM/Engine/Plugin/Commands.pm13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/IM/Engine/Plugin/Commands.pm b/lib/IM/Engine/Plugin/Commands.pm
index e5ecec8..2f18ad4 100644
--- a/lib/IM/Engine/Plugin/Commands.pm
+++ b/lib/IM/Engine/Plugin/Commands.pm
@@ -3,6 +3,7 @@ use Moose;
use Module::Pluggable sub_name => 'commands';
Sub::Name::subname('commands', \&commands);
use List::Util qw(first);
+use Try::Tiny;
extends 'IM::Engine::Plugin';
=head1 NAME
@@ -102,12 +103,14 @@ sub incoming {
my $command = $self->_active_commands->{$command_name};
if (!defined $command) {
my $command_package = $self->_command_package($command_name);
- eval { Class::MOP::load_class($command_package) };
- if ($@) {
- warn $@;
- $self->say((split /\n/, $@)[0]);
- return;
+ return unless try {
+ Class::MOP::load_class($command_package)
}
+ catch {
+ warn $_;
+ $self->say((split /\n/)[0]);
+ return;
+ };
$command = $command_package->new(_ime_plugin => $self);
$self->_active_commands->{$command_name} = $command;
}