Exception: Cloudflair::CloudflareError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/cloudflair/error/cloudflare_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cloudflare_errors) ⇒ CloudflareError

Returns a new instance of CloudflareError.



7
8
9
10
11
# File 'lib/cloudflair/error/cloudflare_error.rb', line 7

def initialize(cloudflare_errors)
  @cloudflare_errors = cloudflare_errors

  super(to_s)
end

Instance Attribute Details

#cloudflare_errorsObject (readonly)

Returns the value of attribute cloudflare_errors.



5
6
7
# File 'lib/cloudflair/error/cloudflare_error.rb', line 5

def cloudflare_errors
  @cloudflare_errors
end

Instance Method Details

#to_sObject



13
14
15
16
17
18
19
20
# File 'lib/cloudflair/error/cloudflare_error.rb', line 13

def to_s
  if cloudflare_errors.empty?
    '[ "An error happened, but no error message/code was given by CloudFlare." (Code: 0000) ]'
  else
    strings = cloudflare_errors.map { |error| "\"#{error['message']}\" (Code: #{error['code']})" }
    "[ #{strings.join ', '} ]"
  end
end