Sha256: 2aa9f2a4f1830c3aaf2abf9a05070ff089d00146ccff3f32ddb28a778c94fe56

Contents?: true

Size: 458 Bytes

Versions: 14

Compression:

Stored size: 458 Bytes

Contents

# frozen_string_literal: true

module Dato
  class ApiError < StandardError
    attr_reader :faraday_error

    def initialize(faraday_error)
      @faraday_error = faraday_error
    end

    def message
      [
        'DatoCMS API Error',
        "Status: #{faraday_error.response[:status]}",
        'Response:',
        JSON.pretty_generate(body)
      ].join("\n")
    end

    def body
      JSON.parse(faraday_error.response[:body])
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dato-0.7.5 lib/dato/api_error.rb
dato-0.7.4 lib/dato/api_error.rb
dato-0.7.3 lib/dato/api_error.rb
dato-0.7.2 lib/dato/api_error.rb
dato-0.7.1 lib/dato/api_error.rb
dato-0.7.0 lib/dato/api_error.rb
dato-0.6.18 lib/dato/api_error.rb
dato-0.6.17 lib/dato/api_error.rb
dato-0.6.16 lib/dato/api_error.rb
dato-0.6.15 lib/dato/api_error.rb
dato-0.6.14 lib/dato/api_error.rb
dato-0.6.12 lib/dato/api_error.rb
dato-0.6.11 lib/dato/api_error.rb
dato-0.6.10 lib/dato/api_error.rb