Exception: Gapic::Rest::DeadlineExceededError

Inherits:
Error show all
Defined in:
lib/gapic/rest/error.rb

Overview

An error class that represents DeadlineExceeded error for Rest with an optional retry root cause.

If the deadline for making a call was exceeded during the rest calls, this exception is thrown wrapping Faraday::TimeoutError.

If there were other exceptions retried before that, the last one will be saved as a "root_cause".

Instance Attribute Summary collapse

Attributes inherited from Error

#details, #headers, #status, #status_code

Instance Attribute Details

#root_causeObject? (readonly)

Returns The exception that was being retried when the Faraday::TimeoutError error occured.

Returns:

  • (Object, nil)

    The exception that was being retried when the Faraday::TimeoutError error occured.



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/gapic/rest/error.rb', line 167

class DeadlineExceededError < Error
  attr_reader :root_cause

  ##
  # @private
  # @param message [String, nil] error message
  # @param status_code [Integer, nil] HTTP status code of this error
  # @param status [String, nil] The text representation of status as parsed from the response body
  # @param details [Object, nil] Details data of this error
  # @param headers [Object, nil] Http headers data of this error
  # @param root_cause [Object, nil] The exception that was being retried
  #   when the Faraday::TimeoutError occured.
  #
  def initialize message, status_code, status: nil, details: nil, headers: nil, root_cause: nil
    super message, status_code, status: status, details: details, headers: headers
    @root_cause = root_cause
  end

  class << self
    ##
    # @private
    # This creates a new error message wrapping the Faraday's one. Additionally
    # it tries to parse and set a detailed message and an error code from
    # from the Google Cloud's response body
    #
    # @param err [Faraday::TimeoutError] the Faraday error to wrap
    #
    # @param root_cause [Object, nil] The exception that was being retried
    #   when the Faraday::TimeoutError occured.
    #
    # @return [ Gapic::Rest::DeadlineExceededError]
    def wrap_faraday_error err, root_cause: nil
      message, status_code, status, details, headers = parse_faraday_error err
      Gapic::Rest::DeadlineExceededError.new message,
                                             status_code,
                                             status: status,
                                             details: details,
                                             headers: headers,
                                             root_cause: root_cause
    end
  end
end