From: Justin Hunter Date: Sat, 25 Jul 2009 16:40:06 +0000 (-0700) Subject: use TryCatch X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=365e4efe4fc2735976e3d4f78716e76abbe30183;p=dbsrgits%2FSQL-Translator-2.0-ish.git use TryCatch --- diff --git a/lib/SQL/Translator.pm b/lib/SQL/Translator.pm index bdca03a..bd07882 100644 --- a/lib/SQL/Translator.pm +++ b/lib/SQL/Translator.pm @@ -1,6 +1,7 @@ use MooseX::Declare; class SQL::Translator { use MooseX::Types::Moose qw(Str); + use TryCatch; use SQL::Translator::Types qw(DBIHandle Parser Producer); has 'parser' => ( @@ -58,12 +59,7 @@ class SQL::Translator { my $role = $class . '::' . $self->producer; Class::MOP::load_class($class); - eval { Class::MOP::load_class($role); }; - if ($@) { - $role = $class . '::SQL::' . $self->producer; - eval { Class::MOP::load_class($role); }; - die $@ if $@; - } + try { Class::MOP::load_class($role) } catch ($e) { $role = $class . '::SQL::' . $self->producer; Class::MOP::load_class($role) } my $producer = $class->new({ schema => $self->parse }); $role->meta->apply($producer);