blob: 8bba63460d2ddb0ed9a95faa412969c1e66d0658 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package Reply::Plugin::LoadClass;
use strict;
use warnings;
use base 'Reply::Plugin';
use Module::Runtime 'use_package_optimistically';
use Try::Tiny;
sub execute {
my $self = shift;
my ($next, @args) = @_;
try {
$next->(@args);
}
catch {
if (/^Can't locate object method "[^"]*" via package "([^"]*)"/) {
use_package_optimistically($1);
$next->(@args);
}
else {
die $_;
}
}
}
1;
|