Class: ShopifyCLI::Theme::Syncer::ErrorReporter
- Inherits:
-
Object
- Object
- ShopifyCLI::Theme::Syncer::ErrorReporter
- Defined in:
- lib/shopify_cli/theme/syncer/error_reporter.rb
Overview
ShopifyCLI::Theme::Syncer::ErrorReporter allows delaying log of errors, mainly to not break the progress bar.
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#delayed_errors ⇒ Object
readonly
Returns the value of attribute delayed_errors.
Instance Method Summary collapse
- #disable! ⇒ Object
- #enable! ⇒ Object
- #has_any_error? ⇒ Boolean
-
#initialize(ctx) ⇒ ErrorReporter
constructor
A new instance of ErrorReporter.
- #report(error_message) ⇒ Object
Constructor Details
#initialize(ctx) ⇒ ErrorReporter
Returns a new instance of ErrorReporter.
13 14 15 16 17 18 |
# File 'lib/shopify_cli/theme/syncer/error_reporter.rb', line 13 def initialize(ctx) @ctx = ctx @has_any_error = false @delay_errors = false @delayed_errors = [] end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
11 12 13 |
# File 'lib/shopify_cli/theme/syncer/error_reporter.rb', line 11 def ctx @ctx end |
#delayed_errors ⇒ Object (readonly)
Returns the value of attribute delayed_errors.
11 12 13 |
# File 'lib/shopify_cli/theme/syncer/error_reporter.rb', line 11 def delayed_errors @delayed_errors end |
Instance Method Details
#disable! ⇒ Object
20 21 22 |
# File 'lib/shopify_cli/theme/syncer/error_reporter.rb', line 20 def disable! @delay_errors = true end |
#enable! ⇒ Object
24 25 26 27 28 |
# File 'lib/shopify_cli/theme/syncer/error_reporter.rb', line 24 def enable! @delay_errors = false @delayed_errors.each { |error| report(error) } @delayed_errors.clear end |
#has_any_error? ⇒ Boolean
39 40 41 |
# File 'lib/shopify_cli/theme/syncer/error_reporter.rb', line 39 def has_any_error? @has_any_error end |
#report(error_message) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/shopify_cli/theme/syncer/error_reporter.rb', line 30 def report() if @delay_errors @delayed_errors << else @has_any_error = true @ctx.error() end end |