Exception: BeyondApi::Error

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, status_code = nil) ⇒ Error

Returns a new instance of Error.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/beyond_api/error.rb', line 7

def initialize(data, status_code = nil)
  data ||= {}

  @error_id          = data["errorId"]
  @details           = data["details"]
  @trace_id          = data["traceId"]
  @error             = data["error"]
  @error_description = data["error_description"]
  @full_message      = data
  @status_code       = status_code

  super(data["message"] || data["error_description"])
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



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

def details
  @details
end

#errorObject (readonly)

Returns the value of attribute error.



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

def error
  @error
end

#error_descriptionObject (readonly)

Returns the value of attribute error_description.



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

def error_description
  @error_description
end

#error_idObject (readonly)

Returns the value of attribute error_id.



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

def error_id
  @error_id
end

#full_messageObject (readonly)

Returns the value of attribute full_message.



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

def full_message
  @full_message
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



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

def status_code
  @status_code
end

#trace_idObject (readonly)

Returns the value of attribute trace_id.



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

def trace_id
  @trace_id
end

Instance Method Details

#to_jsonObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/beyond_api/error.rb', line 21

def to_json
  {
    error_id: @error_id,
    message: @message,
    details: @details,
    error: @error,
    error_description: @error_description,
    trace_id: @trace_id,
    status_code: @status_code
  }
end