/lib/httparty/exceptions.rb

http://github.com/jnunemaker/httparty · Ruby · 33 lines · 14 code · 6 blank · 13 comment · 0 complexity · 130478a1912353c4995d5893bc8072b1 MD5 · raw file

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