Sha256: 747088a47a9ba0d7a44c96f0c8b4aae87d7fad1898adc6468b74d778610fa743

Contents?: true

Size: 982 Bytes

Versions: 47

Compression:

Stored size: 982 Bytes

Contents

# frozen_string_literal: true

module ShopifyCLI
  module Theme
    class Syncer
      ##
      # ShopifyCLI::Theme::Syncer::ErrorReporter allows delaying log of errors,
      # mainly to not break the progress bar.
      #
      class ErrorReporter
        attr_reader :ctx, :delayed_errors

        def initialize(ctx)
          @ctx = ctx
          @has_any_error = false
          @delay_errors = false
          @delayed_errors = []
        end

        def disable!
          @delay_errors = true
        end

        def enable!
          @delay_errors = false
          @delayed_errors.each { |error| report(error) }
          @delayed_errors.clear
        end

        def report(error_message)
          if @delay_errors
            @delayed_errors << error_message
          else
            @has_any_error = true
            @ctx.error(error_message)
          end
        end

        def has_any_error?
          @has_any_error
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.35.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.34.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.33.1 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.33.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.32.1 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.32.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.31.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.30.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.29.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.28.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.27.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.26.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.25.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.24.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.23.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.22.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.21.0 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.20.1 lib/shopify_cli/theme/syncer/error_reporter.rb
shopify-cli-2.20.0 lib/shopify_cli/theme/syncer/error_reporter.rb