Sha256: 3ba807873f2fa53b713a6158a55998827a7675fac4efea4a42044d70bbe4f701

Contents?: true

Size: 648 Bytes

Versions: 4

Compression:

Stored size: 648 Bytes

Contents

module OAuth2
  class Error < StandardError
    attr_reader :response, :code, :description

    # standard error values include:
    # :invalid_request, :invalid_client, :invalid_token, :invalid_grant, :unsupported_grant_type, :invalid_scope
    def initialize(response)
      response.error = self
      @response = response

      message = []

      if response.parsed.is_a?(Hash)
        @code = response.parsed['error']
        @description = response.parsed['error_description']
        message << "#{@code}: #{@description}"
      end

      message << response.body.force_encoding("UTF-8")

      super(message.join("\n"))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
boletosimples-0.0.4 lib/oauth2_patch.rb
boletosimples-0.0.3 lib/oauth2_patch.rb
boletosimples-0.0.2 lib/oauth2_patch.rb
boletosimples-0.0.1 lib/oauth2_patch.rb