Class: LedgerSync::Adaptors::QuickBooksOnline::Util::ErrorMatcher
- Inherits:
-
Object
- Object
- LedgerSync::Adaptors::QuickBooksOnline::Util::ErrorMatcher
show all
- Defined in:
- lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ErrorMatcher.
11
12
13
14
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 11
def initialize(error:)
@error = error
@message = error.message.to_s
end
|
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
8
9
10
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 8
def error
@error
end
|
#message ⇒ Object
Returns the value of attribute message.
8
9
10
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 8
def message
@message
end
|
Instance Method Details
#body ⇒ Object
16
17
18
19
20
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 16
def body
error.response.body
rescue NoMethodError
nil
end
|
#code ⇒ Object
38
39
40
41
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 38
def code
((body && JSON.parse(body).dig('fault', 'error')&.first&.fetch('code')) ||
(body && JSON.parse(body).dig('Fault', 'Error')&.first&.fetch('code'))).to_i
end
|
#detail ⇒ Object
33
34
35
36
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 33
def detail
(body && JSON.parse(body).dig('fault', 'error')&.first&.fetch('detail')) ||
(body && JSON.parse(body).dig('Fault', 'Error')&.first&.fetch('Detail'))
end
|
#error_klass ⇒ Object
22
23
24
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 22
def error_klass
raise NotImplementedError
end
|
#error_message ⇒ Object
26
27
28
29
30
31
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 26
def error_message
(body && JSON.parse(body).dig('fault', 'error')&.first&.fetch('message')) ||
(body && JSON.parse(body).dig('Fault', 'Error')&.first&.fetch('Message')) ||
(body && JSON.parse(body).dig('error')) ||
error.message
end
|
#match? ⇒ Boolean
43
44
45
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 43
def match?
raise NotImplementedError
end
|
#output_message ⇒ Object
47
48
49
|
# File 'lib/ledger_sync/adaptors/quickbooks_online/util/error_matcher.rb', line 47
def output_message
raise NotImplementedError
end
|