Exception: TesoteSdk::Error

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

Overview

Base class. Catch-all only as last resort.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, error_code: nil, http_status: nil, request_id: nil, error_id: nil, retry_after: nil, response_body: nil, request_summary: nil, attempts: nil, cause: nil) ⇒ Error

Returns a new instance of Error.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tesote_sdk/errors.rb', line 9

def initialize(message,
               error_code: nil,
               http_status: nil,
               request_id: nil,
               error_id: nil,
               retry_after: nil,
               response_body: nil,
               request_summary: nil,
               attempts: nil,
               cause: nil)
  super(message)
  @error_code = error_code
  @http_status = http_status
  @request_id = request_id
  @error_id = error_id
  @retry_after = retry_after
  @response_body = response_body
  @request_summary = request_summary
  @attempts = attempts
  @cause_override = cause
end

Instance Attribute Details

#attemptsObject (readonly)

Returns the value of attribute attempts.



6
7
8
# File 'lib/tesote_sdk/errors.rb', line 6

def attempts
  @attempts
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



6
7
8
# File 'lib/tesote_sdk/errors.rb', line 6

def error_code
  @error_code
end

#error_idObject (readonly)

Returns the value of attribute error_id.



6
7
8
# File 'lib/tesote_sdk/errors.rb', line 6

def error_id
  @error_id
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



6
7
8
# File 'lib/tesote_sdk/errors.rb', line 6

def http_status
  @http_status
end

#request_idObject (readonly)

Returns the value of attribute request_id.



6
7
8
# File 'lib/tesote_sdk/errors.rb', line 6

def request_id
  @request_id
end

#request_summaryObject (readonly)

Returns the value of attribute request_summary.



6
7
8
# File 'lib/tesote_sdk/errors.rb', line 6

def request_summary
  @request_summary
end

#response_bodyObject (readonly)

Returns the value of attribute response_body.



6
7
8
# File 'lib/tesote_sdk/errors.rb', line 6

def response_body
  @response_body
end

#retry_afterObject (readonly)

Returns the value of attribute retry_after.



6
7
8
# File 'lib/tesote_sdk/errors.rb', line 6

def retry_after
  @retry_after
end

Instance Method Details

#causeObject



31
32
33
# File 'lib/tesote_sdk/errors.rb', line 31

def cause
  @cause_override || super
end

#inspectObject



49
50
51
52
53
54
55
56
57
# File 'lib/tesote_sdk/errors.rb', line 49

def inspect
  parts = [
    "code=#{error_code.inspect}",
    "status=#{http_status.inspect}",
    "request_id=#{request_id.inspect}",
    "attempts=#{attempts.inspect}"
  ].join(' ')
  "#<#{self.class.name}: #{message} (#{parts})>"
end

#to_hObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/tesote_sdk/errors.rb', line 35

def to_h
  {
    error_code: error_code,
    message: message,
    http_status: http_status,
    request_id: request_id,
    error_id: error_id,
    retry_after: retry_after,
    response_body: response_body,
    request_summary: request_summary,
    attempts: attempts
  }
end