-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improved error-handling #27
improved error-handling #27
Conversation
I made $err to be a hashref, so that it can be expanded in the future with extra fields if needed without breaking backwards compatibility. |
This fix can turn this complex-looking blocking route handler: my $token = eval { $self->get_token('facebook', on_refuse => sub { die \'refused'; }); };
if (my $e = $@) {
if (ref $e eq 'SCALAR' and $$e eq 'refused') {
return $self->render(text => 'refused');
} else {
die $e;
}
}
if ($token) {
# ...
} ...into this: my ($token, $err) = $self->get_token('facebook');
if ($err and $err->{error} eq 'access_denied') {
return $self->render(text => 'refused');
}
if ($token) {
# ...
} |
Of course needs documentation and tests. Will do these if you tell me you want this pull request. |
Pinging for attention from Marcus. |
Ok, been going a bit back and forth on this one, but I think it's an improvement, so I'll accept it if you provide tests and documentation. |
Will do the tests & documentation for this pull request, in a few days. |
- Fix handling of error in param, #27 - Add new helper oauth2->auth_url - Add new helper oauth2->get_token - Add new helper oauth2->providers - Add eventbrite and github as providers - Deprecate on_xxx handlers - Started deprecation process for get_authorize_url() and get_token();
Before, if an error occurred during the authorization stage, the user would just keep on visiting the oauth2 provider in an endless loop. With this patch, at least in blocking mode,
get_token
will return ($token, $err, $state) and the user won't enter an endless loop. The programmer can now easily check $err.If it didn't break backwards compatibility, I would have implemented something similar for the non-blocking mode.