Exception: Safire::Errors::NetworkError

Inherits:
Error
  • Object
show all
Defined in:
lib/safire/errors.rb

Overview

Raised when an HTTP request fails at the network or transport level (connection refused, timeout, SSL handshake failure, etc.).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_description: nil) ⇒ NetworkError

Returns a new instance of NetworkError.



256
257
258
259
# File 'lib/safire/errors.rb', line 256

def initialize(error_description: nil)
  @error_description = error_description
  super(build_message)
end

Instance Attribute Details

#error_descriptionString? (readonly)

Returns the underlying transport error message.

Returns:

  • (String, nil)

    the underlying transport error message



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/safire/errors.rb', line 253

class NetworkError < Error
  attr_reader :error_description

  def initialize(error_description: nil)
    @error_description = error_description
    super(build_message)
  end

  private

  def build_message
    return 'HTTP request failed' unless @error_description

    "HTTP request failed: #{@error_description}"
  end
end