Skip to content

Commit

Permalink
migrate UnexcpectedResponseError to Error class
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmestad committed Jul 11, 2010
1 parent df89ddb commit e150714
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/chargify.rb
Expand Up @@ -17,6 +17,6 @@ module Chargify

# TODO: migrate away from generic errors
# Replace with Chargify::Errors
class UnexpectedResponseError < RuntimeError; end


end
14 changes: 8 additions & 6 deletions lib/chargify/error.rb
Expand Up @@ -9,12 +9,14 @@ def initialize(response=nil)
end
end

class AccessDenied < Base; end # 401 errors
class Forbidden < Base; end # 403 errors
class BadRequest < Base; end # 422 errors
class NotFound < Base; end # 404 errors
class GatewayTimeout < Base; end # 504 errors
class ConnectionFailed < Base; end
class AccessDenied < Base; end # 401 errors
class Forbidden < Base; end # 403 errors
class BadRequest < Base; end # 422 errors
class NotFound < Base; end # 404 errors
class GatewayTimeout < Base; end # 504 errors
class ConnectionFailed < Base; end

class UnexpectedResponse < Base; end

end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/chargify/parser.rb
Expand Up @@ -5,7 +5,7 @@ def parse
begin
Crack::JSON.parse(body)
rescue => e
raise UnexpectedResponseError, "Crack could not parse JSON. It said: #{e.message}. Chargify's raw response: #{body}"
raise(Chargify::Error::UnexpectedResponse.new(e.message), body)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/chargify/subscription_spec.rb
Expand Up @@ -101,7 +101,7 @@
}
lambda {
Chargify::Subscription.create(options)
}.should raise_error(Chargify::UnexpectedResponseError)
}.should raise_error(Chargify::Error::UnexpectedResponse)
end
end

Expand Down

0 comments on commit e150714

Please sign in to comment.