Patch for situations when you broke DBIC, to get clearer error reporting behaviour
Tomas Doran [Mon, 25 Feb 2013 14:36:09 +0000 (14:36 +0000)]
Changes
lib/Catalyst/Authentication/Store/DBIx/Class/User.pm

diff --git a/Changes b/Changes
index ceaa60d..9f0ea3a 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Catalyst-Plugin-Authentication-Store-DBIx-Class
 
+        * Return undef if there isn't a user. This will cause an exception
+          but a more helpful exception (probably from DBIC) than the inability
+          to call a method in this code.
+
 0.1504  2012-10-05
         * Make use_userdata_from_session use inflate_result since this is
           already-stored data, not a "new" object being created
index 0bc8b6f..4e5319c 100644 (file)
@@ -261,7 +261,9 @@ sub can {
     my $self = shift;
     return $self->SUPER::can(@_) || do {
         my ($method) = @_;
-        if (my $code = $self->_user->can($method)) {
+        if (not $self->_user) {
+            undef;
+        } elsif (my $code = $self->_user->can($method)) {
             sub { shift->_user->$code(@_) }
         } elsif (my $accessor =
             try { $self->_user->result_source->column_info($method)->{accessor} }) {