Exception: GandiV5::Error::GandiError

Inherits:
GandiV5::Error show all
Defined in:
lib/gandi_v5/error/gandi_error.rb

Overview

Generic error class for errors returned by Gandi.

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ GandiV5::Error::GandiError

Generate a new GandiV5::Error::GandiError from the hash returned by Gandi.

Parameters:

  • hash (Hash)

    the hash returned by Gandi.

Returns:



10
11
12
13
14
15
16
17
18
# File 'lib/gandi_v5/error/gandi_error.rb', line 10

def self.from_hash(hash)
  hash['errors'] ||= []

  new(
    (hash['errors'].count > 1 ? "\n" : '') +
      hash['errors'].map { |err| "#{err['location']}->#{err['name']}: #{err['description']}" }
                         .join("\n")
  )
end