ruby 1.9 compat when raising ConnectionFailed

This commit is contained in:
Mislav Marohnić 2011-02-28 03:18:30 +01:00
parent 8c5701f8ea
commit c3e5b69507
6 changed files with 13 additions and 18 deletions

View File

@ -73,7 +73,7 @@ module Faraday
@app.call env
rescue Errno::ECONNREFUSED
raise Error::ConnectionFailed, "connection refused"
raise Error::ConnectionFailed, $!
end
end
end

View File

@ -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

View File

@ -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 = {}

View File

@ -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.

View File

@ -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 = {})

View File

@ -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