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.
-
#exception ⇒ Object
Returns the value of attribute exception.
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
- #rescued ⇒ 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 |
#exception ⇒ Object
Returns the value of attribute exception.
6 7 8 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 6 def exception @exception 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.
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 53 54 55 56 57 58 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 28 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
14 15 16 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 14 def request_results_class Eco::API::UseCases::GraphQL::Helpers::Location::Command::Results end |
#rescued ⇒ Object
8 9 10 11 12 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 8 def rescued yield rescue StandardError => e log(:error) { self.exception ||= e. } end |
#results ⇒ Object
Capture results
19 20 21 |
# File 'lib/eco/api/usecases/graphql/samples/location/command/results.rb', line 19 def results @results ||= {} end |