Skip to content
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

ThirdPartyFailure is raised when something gows wrong with provider, but there's no way to catch it. #144

Open
sq9mev opened this issue May 4, 2014 · 1 comment

Comments

@sq9mev
Copy link

sq9mev commented May 4, 2014

There may be many reasons when ThirdPartyFailure raises, eg. generaly it's used in providers when response code from provider is not 200.

Well, eg.
Looking at velruse source i can see no way to catch such en exceptions in my own code, so i can not display human readable message and show it to user - instead ugly 500 appears.

Shouldn't be some way added to catch ThirdPartyFailure eg, just the way velruse.AuthenticationDenied view is set up?

@czekan
Copy link

czekan commented May 4, 2014

The reasonable solution is to return ThirdPartyFailure (and other exceptions that inherit from VelruseException) than raise it.
Than we could register view in our application which will handle the errors the same way we handle AuthenticationComplete and AuthenticationDenied. Eg.:

@view_config(
    context='velruse.exceptions.VelruseException',
    renderer='app:templates/social_login_error.html',
)
def login_error_view(request):
    # do something with it, eg. redirect to home and flash message
    error = request.context.message
    request.session.flash({'type': 'danger', 'messages': [error, ]})
    log.warning(request.context)
    return HTTPFound(location=request.route_url('home'))

We've got fork of forked repo :)(with linkedin_oauth2 support), which includes those changes:
https://github.com/codersmill/velruse/tree/feature/handling_errors

I can prepare proper Pull Request if maintainer accept this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants