class Eco::API::UseCases::GraphQL::Samples::Location # Logic to: Track-down results and errors module Command::Results include Eco::API::UseCases::GraphQL::Helpers::Base::CaseEnv attr_accessor :error def request_results_class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Results end # Capture results def results @results ||= {} end # Errors tracking/logging. # @note it gives feedback on where an error has occurred. # @param page_results [Eco::API::UseCases::GraphQL::Helpers::Locations::Commands::CommandResults] # @param stage [Symbol] used when we launch an update in different phases (i.e. rename, move, etc.) # @return [Boolean] whether or not there was an error def page_errors?(page_results, page, pages, done, total, stage: nil) msg = "Expecting CommandResults object. Given: #{page_results.class}" raise msg unless page_results.is_a?(request_results_class) stage_str = stage ? "'#{stage}' " : '' fingerprint = "#{stage_str}#{page} (of #{pages})" errored = false if page_results.error? errored = true log(:error) { "Error on #{fingerprint}: #{page_results.error.doc.pretty_inspect}" } end if page_results.applied? log(:info) { "Success on #{fingerprint}: #{done} (of #{total}) commands applied!" } elsif page_results.errored? errored = true msg = "Some command failed on #{fingerprint}:\n#{page_results.stats}" unless force_continue? first_errored = page_results.first_errored msg << "The error(s) - #{first_errored.error_msg}\n" end log(:error) { msg } end errored end end end