X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FCDBICompat%2FConstraints.pm;h=bc44462e51054147c111347bec6978cc633618ee;hb=de621449d983d7dbc139687a1d9f157524009942;hp=f712627e4772faf05600cb8bf46e3ad45f7f9fc5;hpb=cc8d8678e3f892f6f20e63bd1e61a17d2f2af288;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/CDBICompat/Constraints.pm b/lib/DBIx/Class/CDBICompat/Constraints.pm index f712627..bc44462 100644 --- a/lib/DBIx/Class/CDBICompat/Constraints.pm +++ b/lib/DBIx/Class/CDBICompat/Constraints.pm @@ -1,4 +1,5 @@ -package DBIx::Class::CDBICompat::Constraints; +package # hide from PAUSE + DBIx::Class::CDBICompat::Constraints; use strict; use warnings; @@ -6,9 +7,9 @@ use warnings; sub constrain_column { my $class = shift; my $col = $class->find_column(+shift) - or return $class->throw("constraint_column needs a valid column"); + or return $class->throw_exception("constraint_column needs a valid column"); my $how = shift - or return $class->throw("constrain_column needs a constraint"); + or return $class->throw_exception("constrain_column needs a constraint"); if (ref $how eq "ARRAY") { my %hash = map { $_ => 1 } @$how; $class->add_constraint(list => $col => sub { exists $hash{ +shift } }); @@ -20,7 +21,7 @@ sub constrain_column { if (my $dispatch = $class->can($try_method)) { $class->$dispatch($col => ($how, @_)); } else { - $class->throw("Don't know how to constrain $col with $how"); + $class->throw_exception("Don't know how to constrain $col with $how"); } } } @@ -28,12 +29,12 @@ sub constrain_column { sub add_constraint { my $class = shift; $class->_invalid_object_method('add_constraint()') if ref $class; - my $name = shift or return $class->throw("Constraint needs a name"); + my $name = shift or return $class->throw_exception("Constraint needs a name"); my $column = $class->find_column(+shift) - or return $class->throw("Constraint $name needs a valid column"); + or return $class->throw_exception("Constraint $name needs a valid column"); my $code = shift - or return $class->throw("Constraint $name needs a code reference"); - return $class->throw("Constraint $name '$code' is not a code reference") + or return $class->throw_exception("Constraint $name needs a code reference"); + return $class->throw_exception("Constraint $name '$code' is not a code reference") unless ref($code) eq "CODE"; #$column->is_constrained(1); @@ -41,7 +42,7 @@ sub add_constraint { "before_set_$column" => sub { my ($self, $value, $column_values) = @_; $code->($value, $self, $column, $column_values) - or return $self->throw( + or return $self->throw_exception( "$class $column fails '$name' constraint with '$value'"); } );