X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FCDBICompat%2FHasA.pm;h=43f760904de21c29c573005fcd199d0fd7379ab8;hb=78bab9cad621ac5e3d1d12b02c41d662dec7a22a;hp=88e7caca3c8c454d9488824ff6f4de9374c4b8e3;hpb=2840de8fbf8506d2edbec5a9c7500136f0fc1c2a;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/CDBICompat/HasA.pm b/lib/DBIx/Class/CDBICompat/HasA.pm index 88e7cac..43f7609 100644 --- a/lib/DBIx/Class/CDBICompat/HasA.pm +++ b/lib/DBIx/Class/CDBICompat/HasA.pm @@ -5,10 +5,10 @@ use warnings; sub has_a { my ($self, $col, $f_class) = @_; - die "No such column ${col}" unless $self->_columns->{$col}; + $self->throw( "No such column ${col}" ) unless $self->_columns->{$col}; eval "require $f_class"; my ($pri, $too_many) = keys %{ $f_class->_primaries }; - die "has_a only works with a single primary key; ${f_class} has more" + $self->throw( "has_a only works with a single primary key; ${f_class} has more" ) if $too_many; $self->add_relationship($col, $f_class, { "foreign.${pri}" => "self.${col}" }, @@ -47,7 +47,7 @@ sub store_has_a { return $self->store_column($rel, $obj); } my $rel_obj = $self->_relationships->{$rel}; - die "Can't set $rel: object $obj is not of class ".$rel_obj->{class} + $self->throw( "Can't set $rel: object $obj is not of class ".$rel_obj->{class} ) unless $obj->isa($rel_obj->{class}); $self->{_relationship_data}{$rel} = $obj; #warn "Storing $obj: ".($obj->_ident_values)[0]; @@ -75,7 +75,7 @@ sub _cond_value { if ( my $rel_obj = $self->_relationships->{$key} ) { my $rel_type = $rel_obj->{attrs}{_type} || ''; if ($rel_type eq 'has_a' && ref $value) { - die "Object $value is not of class ".$rel_obj->{class} + $self->throw( "Object $value is not of class ".$rel_obj->{class} ) unless $value->isa($rel_obj->{class}); $value = ($value->_ident_values)[0]; #warn $value;