Exception: Starling::Errors::BaseError

Inherits:
StandardError
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/starling/errors/base_error.rb

Overview

A basic implementation of an error thrown from a Faraday::Response::Middleware, receiving the Faraday environment as an argument, providing access to the response status and body

Direct Known Subclasses

ApiError

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ BaseError

Returns a new instance of BaseError.

Parameters:

  • env

    The Faraday environment, providing access to the response



12
13
14
# File 'lib/starling/errors/base_error.rb', line 12

def initialize(env)
  @env = env
end

Instance Method Details

#messageString Also known as: to_s

Returns a helpful message explaining the error, incorporating the HTTP status code and body returned.

Returns:

  • (String)

    a helpful message explaining the error, incorporating the HTTP status code and body returned



21
22
23
24
25
26
# File 'lib/starling/errors/base_error.rb', line 21

def message
  message = status.to_s
  message += ": #{body}" if body

  message
end