diff options
Diffstat (limited to '')
-rw-r--r-- | lib/Net/HTTP/Console/Role/Plugins.pm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Net/HTTP/Console/Role/Plugins.pm b/lib/Net/HTTP/Console/Role/Plugins.pm index a3136f2..d7bf7b5 100644 --- a/lib/Net/HTTP/Console/Role/Plugins.pm +++ b/lib/Net/HTTP/Console/Role/Plugins.pm @@ -4,6 +4,8 @@ use MooseX::Declare; role Net::HTTP::Console::Role::Plugins { + use Try::Tiny; + has dispatchers => ( is => 'rw', isa => 'ArrayRef[Str]', @@ -33,6 +35,17 @@ role Net::HTTP::Console::Role::Plugins { \@p; }, ); + + method dispatch ($input) { + my $result; + try { + foreach ($self->all_plugins) { + last if ($result = $_->dispatch($input)); + } + }catch{ + print "[ERROR]: ".$_; + }; + } } 1; |