mirror of
https://github.com/lostisland/faraday.git
synced 2025-08-29 00:03:58 -04:00
ruby 1.9 compat when raising ConnectionFailed
This commit is contained in:
parent
8c5701f8ea
commit
c3e5b69507
@ -73,7 +73,7 @@ module Faraday
|
||||
|
||||
@app.call env
|
||||
rescue Errno::ECONNREFUSED
|
||||
raise Error::ConnectionFailed, "connection refused"
|
||||
raise Error::ConnectionFailed, $!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -33,8 +33,8 @@ module Faraday
|
||||
end
|
||||
|
||||
@app.call env
|
||||
rescue ::Excon::Errors::SocketError => e
|
||||
raise Error::ConnectionFailed.new(e)
|
||||
rescue ::Excon::Errors::SocketError
|
||||
raise Error::ConnectionFailed, $!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -51,8 +51,8 @@ module Faraday
|
||||
else
|
||||
http.request http_request, env[:body]
|
||||
end
|
||||
rescue Errno::ECONNREFUSED => e
|
||||
raise Error::ConnectionFailed.new(e)
|
||||
rescue Errno::ECONNREFUSED
|
||||
raise Error::ConnectionFailed, $!
|
||||
end
|
||||
|
||||
response_headers = {}
|
||||
|
@ -25,7 +25,7 @@ module Faraday
|
||||
|
||||
@app.call env
|
||||
rescue Errno::ECONNREFUSED
|
||||
raise Error::ConnectionFailed.new(Errno::ECONNREFUSED)
|
||||
raise Error::ConnectionFailed, $!
|
||||
end
|
||||
|
||||
# TODO: build in support for multipart streaming if patron supports it.
|
||||
|
@ -44,7 +44,7 @@ module Faraday
|
||||
|
||||
@app.call env
|
||||
rescue Errno::ECONNREFUSED
|
||||
raise Error::ConnectionFailed.new(Errno::ECONNREFUSED)
|
||||
raise Error::ConnectionFailed, $!
|
||||
end
|
||||
|
||||
def in_parallel(options = {})
|
||||
|
@ -1,28 +1,23 @@
|
||||
module Faraday
|
||||
module Error
|
||||
class ClientError < StandardError
|
||||
def initialize(exception)
|
||||
@inner_exception = exception
|
||||
end
|
||||
|
||||
def message
|
||||
@inner_exception.respond_to?(:message) ?
|
||||
@inner_exception.message :
|
||||
@inner_exception.to_s
|
||||
def initialize(ex)
|
||||
super(ex.respond_to?(:message) ? ex.message : ex.to_s)
|
||||
@wrapped_exception = ex
|
||||
end
|
||||
|
||||
def backtrace
|
||||
@inner_exception.backtrace
|
||||
@wrapped_exception.backtrace
|
||||
end
|
||||
|
||||
alias to_str message
|
||||
|
||||
def to_s
|
||||
@inner_exception.to_s
|
||||
@wrapped_exception.to_s
|
||||
end
|
||||
|
||||
def inspect
|
||||
@inner_exception.inspect
|
||||
%(#<#{self.class}>)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user