Skip to content

Commit 5da83ac

Browse files
committed
Borrow the list of http errors from bundler
1 parent 935ba11 commit 5da83ac

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

sentry-ruby/lib/sentry/transport/http_transport.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ class HTTPTransport < Transport
1414
RATE_LIMIT_HEADER = "x-sentry-rate-limits"
1515
USER_AGENT = "sentry-ruby/#{Sentry::VERSION}"
1616

17-
NET_HTTP_ERRORS = [
18-
Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED,
19-
Errno::ETIMEDOUT, Errno::EHOSTUNREACH, Errno::ENETUNREACH,
20-
Timeout::Error,
21-
::Net::HTTPBadResponse, ::Net::HTTPHeaderSyntaxError, ::Net::ProtocolError
22-
]
17+
# The list of errors ::Net::HTTP is known to raise
18+
# See https://github.com/ruby/ruby/blob/b0c639f249165d759596f9579fa985cb30533de6/lib/bundler/fetcher.rb#L281-L286
19+
HTTP_ERRORS = [
20+
Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
21+
Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
22+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
23+
Zlib::BufError, Errno::EHOSTUNREACH, Errno::ECONNREFUSED
24+
].freeze
25+
2326

2427
def initialize(*args)
2528
super
@@ -65,7 +68,7 @@ def send_data(data)
6568

6669
raise Sentry::ExternalError, error_info
6770
end
68-
rescue SocketError, *NET_HTTP_ERRORS => e
71+
rescue SocketError, *HTTP_ERRORS => e
6972
raise Sentry::ExternalError.new(e&.message)
7073
end
7174

0 commit comments

Comments
 (0)