Sha256: c9cee244236d9e0f161eb754ee5ca17c897b6da6c39a0b424942f96dce7044d7
Contents?: true
Size: 1.4 KB
Versions: 3
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module LedgerSync module Ledgers module QuickBooksOnline class Util class ErrorMatcher attr_reader :error, :message def initialize(error:) @error = error @message = error.message.to_s end def body error.response.body rescue NoMethodError nil end def error_class raise NotImplementedError end 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 def detail (body && JSON.parse(body).dig('fault', 'error')&.first&.fetch('detail')) || (body && JSON.parse(body).dig('Fault', 'Error')&.first&.fetch('Detail')) end 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 def match? raise NotImplementedError end def output_message raise NotImplementedError end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems