Skip to content

Instantly share code, notes, and snippets.

@kennuzzo
Created April 3, 2015 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennuzzo/fcd1ab47726f34f3ca8a to your computer and use it in GitHub Desktop.
Save kennuzzo/fcd1ab47726f34f3ca8a to your computer and use it in GitHub Desktop.
# include 'doorkeeper_helpers' in doorkeeper intializer
# raise Doorkeeper::Errors::InvalidResourceOwner
# remember to add the error message translation to the doorkeeper locale yaml.
# in lib/doorkeeper/helpers/doorkeeper_helpers.rb
module Doorkeeper
module Helpers::Controller
alias_method :old, :get_error_response_from_exception
def get_error_response_from_exception(exception)
error_name = case exception
when Errors::InvalidResourceOwner
:invalid_resource_owner
end
if error_name
OAuth::ErrorResponse.new name: error_name, state: params[:state]
else
old exception
end
end
end
module Errors
class InvalidResourceOwner < DoorkeeperError; end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment