From: Tomas Doran Date: Mon, 25 Feb 2013 14:36:09 +0000 (+0000) Subject: Patch for situations when you broke DBIC, to get clearer error reporting behaviour X-Git-Tag: 0.1505~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9821fc6a414270abd6085c89ee3aa629f1fa5cb9;p=catagits%2FCatalyst-Authentication-Store-DBIx-Class.git Patch for situations when you broke DBIC, to get clearer error reporting behaviour --- diff --git a/Changes b/Changes index ceaa60d..9f0ea3a 100644 --- 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 diff --git a/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm b/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm index 0bc8b6f..4e5319c 100644 --- a/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm +++ b/lib/Catalyst/Authentication/Store/DBIx/Class/User.pm @@ -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} }) {