requires 'MRO::Compat' => '0.05';
requires 'Scalar::Util' => '1.18';
requires 'Sub::Name' => '0.04';
+requires 'Try::Tiny' => '0.02';
requires 'Task::Weaken';
test_requires 'File::Spec';
use Carp 'confess';
use Scalar::Util 'weaken', 'reftype', 'blessed';
+use Try::Tiny;
use Class::MOP::Class;
use Class::MOP::Attribute;
my $found;
my %exceptions;
for my $class (@classes) {
- my $e = _try_load_one_class($class);
+ my ($fail, $e) = _try_load_one_class($class);
- if ($e) {
+ if ($fail) {
my $pmfile = _class_to_pmfile($class);
$exceptions{$class} = $e;
last if $e !~ /^Can't locate \Q$pmfile\E in \@INC/;
my $file = _class_to_pmfile($class);
- return do {
- local $@;
+ my ($failed, $error);
+ try {
local $SIG{__DIE__};
- eval { require($file) };
- $@;
+ require($file);
+ }
+ catch {
+ $failed = 1;
+ $error = $_;
};
+
+ return $failed, $error;
}
sub load_class {
use Carp 'confess';
use Scalar::Util 'blessed', 'weaken';
+use Try::Tiny;
our $VERSION = '0.94';
$VERSION = eval $VERSION;
else {
my $inline_me = ($generate_as_inline_methods && $self->associated_class->instance_metaclass->is_inlinable);
my $method;
- eval {
+ try {
if ( $method_ctx ) {
my $desc = "accessor $accessor";
if ( $accessor ne $self->name ) {
name => $accessor,
definition_context => $method_ctx,
);
+ }
+ catch {
+ confess "Could not create the '$type' method for " . $self->name . " because : $_";
};
- confess "Could not create the '$type' method for " . $self->name . " because : $@" if $@;
$self->associate_method($method);
return ($accessor, $method);
}
use Scalar::Util 'blessed', 'reftype', 'weaken';
use Sub::Name 'subname';
use Devel::GlobalDestruction 'in_global_destruction';
+use Try::Tiny;
our $VERSION = '0.94';
$VERSION = eval $VERSION;
$self->get_attribute_map->{$attr_name} = $attribute;
# invalidate package flag here
- my $e = do {
- local $@;
+ try {
local $SIG{__DIE__};
- eval { $attribute->install_accessors() };
- $@;
- };
- if ( $e ) {
- $self->remove_attribute($attr_name);
- die $e;
+ $attribute->install_accessors();
}
+ catch {
+ $self->remove_attribute($attr_name);
+ die $_;
+ };
return $attribute;
}