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=b90d11cf4ab880edfcd8af359b31fda74cbcd5eb;hpb=9bc6db133eae500322e0e3670d5509d27d208f9e;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/CDBICompat/HasA.pm b/lib/DBIx/Class/CDBICompat/HasA.pm index b90d11c..43f7609 100644 --- a/lib/DBIx/Class/CDBICompat/HasA.pm +++ b/lib/DBIx/Class/CDBICompat/HasA.pm @@ -5,15 +5,14 @@ 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}" }, { _type => 'has_a' } ); - $self->delete_accessor($col); $self->mk_group_accessors('has_a' => $col); return 1; } @@ -48,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]; @@ -76,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;