Skip to content

Commit 8694de0

Browse files
committed
Move foul errors into exceptions.rb
No point in a second file with just that.
1 parent 8cccc98 commit 8694de0

File tree

4 files changed

+21
-28
lines changed

4 files changed

+21
-28
lines changed

lib/httparty.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
require 'httparty/decompressor'
1616
require 'httparty/text_encoder'
1717
require 'httparty/headers_processor'
18-
require 'httparty/common_errors'
1918

2019
# @see HTTParty::ClassMethods
2120
module HTTParty

lib/httparty/common_errors.rb

Lines changed: 0 additions & 26 deletions
This file was deleted.

lib/httparty/exceptions.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
# frozen_string_literal: true
22

33
module HTTParty
4+
FOUL_ERRORS = [
5+
EOFError,
6+
Errno::ECONNABORTED,
7+
Errno::ECONNREFUSED,
8+
Errno::ECONNRESET,
9+
Errno::EHOSTUNREACH,
10+
Errno::EINVAL,
11+
Errno::ENETUNREACH,
12+
Errno::ENOTSOCK,
13+
Errno::EPIPE,
14+
Errno::ETIMEDOUT,
15+
Net::HTTPBadResponse,
16+
Net::HTTPHeaderSyntaxError,
17+
Net::ProtocolError,
18+
Net::ReadTimeout,
19+
OpenSSL::SSL::SSLError,
20+
SocketError,
21+
Timeout::Error # Also covers subclasses like Net::OpenTimeout
22+
].freeze
23+
424
# @abstract Exceptions raised by HTTParty inherit from Error
525
class Error < StandardError; end
626

lib/httparty/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def perform(&block)
172172
result = handle_unauthorized
173173
result ||= handle_response(chunked_body, &block)
174174
result
175-
rescue *CommonErrors::NETWORK_ERRORS => e
175+
rescue *FOUL_ERRORS => e
176176
raise options[:foul] ? HTTParty::Foul.new("#{e.class}: #{e.message}") : e
177177
end
178178
end

0 commit comments

Comments
 (0)