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.



205
206
207
208
# File 'lib/safire/errors.rb', line 205

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



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/safire/errors.rb', line 202

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