Permalink
Browse files

Merge pull request #260 from dpree/master

Add HTTParty::Error base class. Refs #209.
  • Loading branch information...
2 parents be7166c + 5621c87 commit 6cf4fc7df22c446412a3947da2303caa06163289 @jnunemaker committed Nov 30, 2013
Showing with 29 additions and 3 deletions.
  1. +6 −3 lib/httparty/exceptions.rb
  2. +23 −0 spec/httparty/exception_spec.rb
View
9 lib/httparty/exceptions.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
View
23 spec/httparty/exception_spec.rb
@@ -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 6cf4fc7

Please sign in to comment.