Sha256: ae04ded7d71952a9ddae6d80874d28d9ee0f0584660561fd28aa2eee19283a6b

Contents?: true

Size: 649 Bytes

Versions: 14

Compression:

Stored size: 649 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

14 entries across 14 versions & 1 rubygems

Version Path
boletosimples-0.6.0 lib/oauth2_patch.rb
boletosimples-0.5.0 lib/oauth2_patch.rb
boletosimples-0.4.2 lib/oauth2_patch.rb
boletosimples-0.4.1 lib/oauth2_patch.rb
boletosimples-0.4.0 lib/oauth2_patch.rb
boletosimples-0.3.1 lib/oauth2_patch.rb
boletosimples-0.3.0 lib/oauth2_patch.rb
boletosimples-0.2.3 lib/oauth2_patch.rb
boletosimples-0.2.2 lib/oauth2_patch.rb
boletosimples-0.2.0 lib/oauth2_patch.rb
boletosimples-0.1.1 lib/oauth2_patch.rb
boletosimples-0.0.7 lib/oauth2_patch.rb
boletosimples-0.0.6 lib/oauth2_patch.rb
boletosimples-0.0.5 lib/oauth2_patch.rb