Skip to content


Subversion checkout URL

You can clone with
Download ZIP


OAuthException in a decorator can't be handled #12

jace opened this Issue · 2 comments

3 participants


The authorized_handler method raises OAuthException if the OAuth process fails. However, since this method is a decorator, there's no way to write an exception handler that can display a friendly error message to the user. Instead, the user sees a 500 internal server error.

Relevant code:



I had to manually apply the decorator and it was a real pain.

I have 2 suggestions:

  1. Split the decorators into 2 methods: one for the functionality, one which makes it a decorator. That way if one wanted to, one could easily just call the “functionality” method and just use its return value.
  2. Have the decorators catch all exceptions which occur before calling the wrapped function, and if an exception is raised, just pass it to the wrapped function in a specific named argument. (Similar to Node callbacks.) The wrapped functions can then just check whether the error arg is not None and if so deal with it.

I wrapped the decorator with another decorator (trapping this very exception) but it's not ideal, I agree. It would be nice to have a authorize() method returning the data, or throwing whatever exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.