lib/freno/client/request.rb in freno-client-0.8.1 vs lib/freno/client/request.rb in freno-client-0.8.2

- old
+ new

@@ -1,38 +1,39 @@ +# frozen_string_literal: true + require_relative "preconditions" require_relative "result" require_relative "errors" module Freno class Client class Request - include Freno::Client::Preconditions - attr_reader :faraday, :args, :options - attr_reader :raise_on_timeout + attr_reader :faraday, :args, :options, :raise_on_timeout def self.perform(**kwargs) new(**kwargs).perform end def initialize(**kwargs) @args = kwargs @faraday = kwargs.delete(:faraday) || nil - @options = kwargs.delete(:options) || Hash.new + @options = kwargs.delete(:options) || {} @raise_on_timeout = options.fetch(:raise_on_timeout, true) @verb = options.fetch(:verb, :head) end def perform response = request(verb, path, params) process_response(response) - rescue Faraday::TimeoutError => ex - raise Freno::Error.new(ex) if raise_on_timeout + rescue Faraday::TimeoutError => error + raise Freno::Error, error if raise_on_timeout + Result.from_meaning(:request_timeout) - rescue => ex - raise Freno::Error.new(ex) + rescue StandardError => error + raise Freno::Error, error end protected def request(verb, path, params)