X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FHasOne.pm;h=fd8be7e68afbbd3da926e3604556f18f067e9ebd;hb=ed7ab0f4ce1a9118ea6285ee562ef003085a6b64;hp=33a06411700a48b8dc12c1790d2603e512ba2cab;hpb=2339d6c7502b7a5d9b20acc573184960ea2102a6;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index 33a0641..fd8be7e 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -4,6 +4,7 @@ package # hide from PAUSE use strict; use warnings; use Carp::Clan qw/^DBIx::Class/; +use Try::Tiny; our %_pod_inherit_config = ( @@ -60,10 +61,10 @@ sub _has_one { sub _get_primary_key { my ( $class, $target_class ) = @_; $target_class ||= $class; - my ($pri, $too_many) = eval { $target_class->_pri_cols }; - $class->throw_exception( - "Can't infer join condition on ${target_class}: $@" - ) if $@; + my ($pri, $too_many) = try { $target_class->_pri_cols } + catch { + $class->throw_exception("Can't infer join condition on ${target_class}: $@"); + }; $class->throw_exception( "might_have/has_one can only infer join for a single primary key; ".