Module: Eco::API::UseCases::GraphQL::Samples::Location::Command::Results
- Includes:
- Helpers::Base::CaseEnv
- Included in:
- DSL
- Defined in:
- lib/eco/api/usecases/graphql/samples/location/command/results.rb
Overview
Logic to: Track-down results and errors
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
Attributes included from Helpers::Base::ErrorHandling
Attributes included from Language::AuxiliarLogger
Instance Method Summary collapse
-
#page_errors?(page_results, page, pages, done, total, stage: nil) ⇒ Boolean
Errors tracking/logging.
- #request_results_class ⇒ Object
-
#results ⇒ Object
Capture results.
Methods included from Language::AuxiliarLogger
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
6 7 8 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 6 def error @error end |
Instance Method Details
#page_errors?(page_results, page, pages, done, total, stage: nil) ⇒ Boolean
Note:
it gives feedback on where an error has occurred.
Errors tracking/logging.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 22 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 |
#request_results_class ⇒ Object
8 9 10 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 8 def request_results_class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Results end |
#results ⇒ Object
Capture results
13 14 15 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 13 def results @results ||= {} end |