Sha256: 78a1cc76d58293c2c2da0ae9fa797f2d5815d6da23385c398dfd4f8d90396662

Contents?: true

Size: 834 Bytes

Versions: 6

Compression:

Stored size: 834 Bytes

Contents

require_relative './task_exception'

module Builderator
  module Util
    ##
    # Exception raised if a safety limit is exceeded
    ##
    class LimitException < TaskException
      attr_reader :resources

      def initialize(klass, task, resources)
        super(:limit, task, :yellow)

        @klass = klass
        @resources = resources
      end

      def count
        @resources.size
      end

      def limit
        @klass::LIMIT
      end

      def resource
        @klass.name
      end

      def message
        "Safety limit exceeded for task `#{ task }`: Count #{ count } is"\
        " greater than the limit of #{ limit } set in #{ resource }. Please"\
        " re-run this task with the --no-limit flag if you are sure this is"\
        " the correct set of resources to delete."
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
builderator-0.3.15 lib/builderator/util/limit_exception.rb
builderator-0.3.14 lib/builderator/util/limit_exception.rb
builderator-0.3.13 lib/builderator/util/limit_exception.rb
builderator-0.3.12 lib/builderator/util/limit_exception.rb
builderator-0.3.11 lib/builderator/util/limit_exception.rb
builderator-0.3.10 lib/builderator/util/limit_exception.rb