From: Peter Rabbitson <ribasushi@cpan.org>
Date: Sun, 27 Jul 2014 16:39:31 +0000 (+0200)
Subject: Upgrade the "too many args on customcond" warning from 1adbd3f to an exception
X-Git-Tag: v0.082800~105
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7967dcecdd86e803cece3031ebbe6a717bc73086;p=dbsrgits%2FDBIx-Class.git

Upgrade the "too many args on customcond" warning from 1adbd3f to an exception
---

diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm
index c03c8da..c5feb09 100644
--- a/lib/DBIx/Class/ResultSource.pm
+++ b/lib/DBIx/Class/ResultSource.pm
@@ -1864,8 +1864,8 @@ sub _resolve_relationship_condition {
 
     ($ret->{condition}, $ret->{join_free_condition}, my @extra) = $args->{condition}->($cref_args);
 
-    # FIXME sanity check
-    carp_unique('A custom condition coderef can return at most 2 conditions: extra return values discarded')
+    # sanity check
+    $self->throw_exception("A custom condition coderef can return at most 2 conditions, but $exception_rel_id returned extra values: @extra")
       if @extra;
 
     if (my $jfc = $ret->{join_free_condition}) {
diff --git a/t/relationship/custom.t b/t/relationship/custom.t
index 131ebe1..5bc52d4 100644
--- a/t/relationship/custom.t
+++ b/t/relationship/custom.t
@@ -307,4 +307,9 @@ is_deeply
   'set from related via coderef cond inflates properly',
 ;
 
+throws_ok {
+  local $schema->source('Track')->relationship_info('cd_cref_cond')->{cond} = sub { 1,2,3 };
+  $schema->resultset('Track')->find({ cd_cref_cond => {} });
+} qr/\QA custom condition coderef can return at most 2 conditions, but relationship 'cd_cref_cond' on source 'Track' returned extra values: 3/;
+
 done_testing;