Exception: Intercom::IntercomError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/intercom/errors.rb

Overview

Base class exception from which all public Intercom exceptions will be derived

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, context = {}) ⇒ IntercomError

Returns a new instance of IntercomError.


6
7
8
9
10
11
12
# File 'lib/intercom/errors.rb', line 6

def initialize(message, context={})
  @http_code = context[:http_code]
  @application_error_code = context[:application_error_code]
  @field = context[:field]
  @request_id = context[:request_id]
  super(message)
end

Instance Attribute Details

#application_error_codeObject (readonly)

Returns the value of attribute application_error_code


5
6
7
# File 'lib/intercom/errors.rb', line 5

def application_error_code
  @application_error_code
end

#fieldObject (readonly)

Returns the value of attribute field


5
6
7
# File 'lib/intercom/errors.rb', line 5

def field
  @field
end

#http_codeObject (readonly)

Returns the value of attribute http_code


5
6
7
# File 'lib/intercom/errors.rb', line 5

def http_code
  @http_code
end

#request_idObject (readonly)

Returns the value of attribute request_id


5
6
7
# File 'lib/intercom/errors.rb', line 5

def request_id
  @request_id
end

Instance Method Details

#inspectObject


13
14
15
16
17
18
19
# File 'lib/intercom/errors.rb', line 13

def inspect
  attributes = instance_variables.map do |var|
    value = instance_variable_get(var).inspect
    "#{var}=#{value}"
  end
  "##{self.class.name}:#{message} #{attributes.join(' ')}"
end

#to_hashObject


20
21
22
23
# File 'lib/intercom/errors.rb', line 20

def to_hash
  {message: message}
    .merge(Hash[instance_variables.map{ |var| [var[1..-1], instance_variable_get(var)] }])
end