Class: LedgerSync::QuickBooksOnline::Util::ErrorMatcher
- Inherits:
-
Object
- Object
- LedgerSync::QuickBooksOnline::Util::ErrorMatcher
show all
- Defined in:
- lib/ledger_sync/quickbooks_online/util/error_matcher.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ErrorMatcher.
10
11
12
13
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 10
def initialize(error:)
@error = error
@message = error.message.to_s
end
|
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
7
8
9
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 7
def error
@error
end
|
#message ⇒ Object
Returns the value of attribute message.
7
8
9
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 7
def message
@message
end
|
Instance Method Details
#body ⇒ Object
15
16
17
18
19
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 15
def body
@body ||= error.response.body
rescue NoMethodError
nil
end
|
#code ⇒ Object
40
41
42
43
44
45
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 40
def code
return if body.blank?
fault&.fetch('code') ||
fault&.fetch('code').to_i
end
|
#detail ⇒ Object
33
34
35
36
37
38
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 33
def detail
return if body.blank?
fault&.fetch('detail') ||
fault&.fetch('Detail')
end
|
#error_class ⇒ Object
21
22
23
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 21
def error_class
raise NotImplementedError
end
|
#error_message ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 25
def error_message
return error.message unless body
fault&.fetch('message', nil) ||
fault&.fetch('Message', nil) ||
parsed_body['error']
end
|
#match? ⇒ Boolean
47
48
49
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 47
def match?
raise NotImplementedError
end
|
#output_message ⇒ Object
55
56
57
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 55
def output_message
raise NotImplementedError
end
|
#parsed_body ⇒ Object
51
52
53
|
# File 'lib/ledger_sync/quickbooks_online/util/error_matcher.rb', line 51
def parsed_body
@parsed_body ||= JSON.parse(body)
end
|