lib/freno/client/request.rb in freno-client-0.3.0 vs lib/freno/client/request.rb in freno-client-0.4.0
- old
+ new
@@ -1,7 +1,8 @@
-require_relative 'preconditions'
-require_relative 'result'
+require_relative "preconditions"
+require_relative "result"
+require_relative "errors"
module Freno
class Client
class Request
@@ -22,17 +23,16 @@
@raise_on_timeout = options.fetch(:raise_on_timeout, true)
@verb = options.fetch(:verb, :head)
end
def perform
- begin
- response = request(verb, path)
- rescue Faraday::TimeoutError => ex
- raise ex if raise_on_timeout
- Result.from_meaning(:request_timeout)
- else
- process_response(response)
- end
+ response = request(verb, path)
+ process_response(response)
+ rescue Faraday::TimeoutError => ex
+ raise Freno::Error.new(ex) if raise_on_timeout
+ Result.from_meaning(:request_timeout)
+ rescue => ex
+ raise Freno::Error.new(ex)
end
protected
def request(verb, path)