Class: LedgerSync::Ledgers::TestLedger::Util::LedgerErrorParser

Inherits:
ErrorParser
  • Object
show all
Defined in:
lib/ledger_sync/test/support/test_ledger/util/ledger_error_parser.rb

Defined Under Namespace

Classes: AuthenticationMatcher, AuthorizationMatcher, ClientMatcher, ThrottleMatcher

Constant Summary collapse

PARSERS =
[
  AuthenticationMatcher,
  AuthorizationMatcher,
  ClientMatcher,
  ThrottleMatcher
].freeze

Instance Attribute Summary collapse

Attributes inherited from ErrorParser

#error

Instance Method Summary collapse

Methods inherited from ErrorParser

#error_class

Constructor Details

#initialize(client:, error:) ⇒ LedgerErrorParser

Returns a new instance of LedgerErrorParser.



81
82
83
84
# File 'lib/ledger_sync/test/support/test_ledger/util/ledger_error_parser.rb', line 81

def initialize(client:, error:)
  @client = client
  super(error: error)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



79
80
81
# File 'lib/ledger_sync/test/support/test_ledger/util/ledger_error_parser.rb', line 79

def client
  @client
end

Instance Method Details

#parseObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/ledger_sync/test/support/test_ledger/util/ledger_error_parser.rb', line 86

def parse
  PARSERS.map do |parser|
    matcher = parser.new(error: error)
    next unless matcher.match?

    return matcher.error_class.new(
      client: client,
      message: matcher.output_message,
      response: error
    )
  end
  nil
end