Skip to content

Commit

Permalink
Borrow the list of http errors from bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
natikgadzhi committed Nov 27, 2023
1 parent 60b0fa8 commit 5ffa6dc
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions sentry-ruby/lib/sentry/transport/http_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ class HTTPTransport < Transport
RATE_LIMIT_HEADER = "x-sentry-rate-limits"
USER_AGENT = "sentry-ruby/#{Sentry::VERSION}"

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


def initialize(*args)
super
Expand Down Expand Up @@ -65,7 +68,7 @@ def send_data(data)

raise Sentry::ExternalError, error_info
end
rescue SocketError, *NET_HTTP_ERRORS => e
rescue SocketError, *HTTP_ERRORS => e
raise Sentry::ExternalError.new(e&.message)
end

Expand Down

0 comments on commit 5ffa6dc

Please sign in to comment.