PageRenderTime 45ms CodeModel.GetById 37ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/httparty/exceptions.rb

http://github.com/jnunemaker/httparty
Ruby | 33 lines | 14 code | 6 blank | 13 comment | 0 complexity | 130478a1912353c4995d5893bc8072b1 MD5 | raw file
 1module HTTParty
 2  # @abstact Exceptions raised by HTTParty inherit from Error
 3  class Error < StandardError; end
 4
 5  # Exception raised when you attempt to set a non-existent format
 6  class UnsupportedFormat < Error; end
 7
 8  # Exception raised when using a URI scheme other than HTTP or HTTPS
 9  class UnsupportedURIScheme < Error; end
10
11  # @abstract Exceptions which inherit from ResponseError contain the Net::HTTP
12  # response object accessible via the {#response} method.
13  class ResponseError < Error
14    # Returns the response of the last request
15    # @return [Net::HTTPResponse] A subclass of Net::HTTPResponse, e.g.
16    # Net::HTTPOK
17    attr_reader :response
18
19    # Instantiate an instance of ResponseError with a Net::HTTPResponse object
20    # @param [Net::HTTPResponse]
21    def initialize(response)
22      @response = response
23      super(response)
24    end
25  end
26
27  # Exception that is raised when request has redirected too many times.
28  # Calling {#response} returns the Net:HTTP response object.
29  class RedirectionTooDeep < ResponseError; end
30
31  # Exception that is raised when request redirects and location header is present more than once
32  class DuplicateLocationHeader < ResponseError; end
33end