Permalink
Browse files

Add HTTParty::Error base class. Refs #209.

  • Loading branch information...
1 parent be7166c commit 5621c872dc766ba73cde3065e80751030cf6ba7b @bsingr bsingr committed Nov 28, 2013
Showing with 29 additions and 3 deletions.
  1. +6 −3 lib/httparty/exceptions.rb
  2. +23 −0 spec/httparty/exception_spec.rb
@@ -1,13 +1,16 @@
module HTTParty
+ # @abstact Exceptions raised by HTTParty inherit from Error
+ class Error < StandardError; end
+
# Exception raised when you attempt to set a non-existant format
- class UnsupportedFormat < StandardError; end
+ class UnsupportedFormat < Error; end
# Exception raised when using a URI scheme other than HTTP or HTTPS
- class UnsupportedURIScheme < StandardError; end
+ class UnsupportedURIScheme < Error; end
# @abstract Exceptions which inherit from ResponseError contain the Net::HTTP
# response object accessible via the {#response} method.
- class ResponseError < StandardError
+ class ResponseError < Error
# Returns the response of the last request
# @return [Net::HTTPResponse] A subclass of Net::HTTPResponse, e.g.
# Net::HTTPOK
@@ -0,0 +1,23 @@
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
+
+describe HTTParty::Error do
+ subject { described_class }
+
+ its(:ancestors) { should include(StandardError) }
+
+ describe HTTParty::UnsupportedFormat do
+ its(:ancestors) { should include(HTTParty::Error) }
+ end
+
+ describe HTTParty::UnsupportedURIScheme do
+ its(:ancestors) { should include(HTTParty::Error) }
+ end
+
+ describe HTTParty::ResponseError do
+ its(:ancestors) { should include(HTTParty::Error) }
+ end
+
+ describe HTTParty::RedirectionTooDeep do
+ its(:ancestors) { should include(HTTParty::ResponseError) }
+ end
+end

0 comments on commit 5621c87

Please sign in to comment.