Exception: Builderator::Util::LimitException

Inherits:
TaskException
  • Object
show all
Defined in:
lib/builderator/util/limit_exception.rb

Overview

Exception raised if a safety limit is exceeded

Constant Summary collapse

DEFAULT_LIMIT =
4

Instance Attribute Summary collapse

Attributes inherited from TaskException

#task

Instance Method Summary collapse

Methods inherited from TaskException

#status

Constructor Details

#initialize(resource_name, task, resources) ⇒ LimitException

Returns a new instance of LimitException.



14
15
16
17
18
19
# File 'lib/builderator/util/limit_exception.rb', line 14

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

  @resource_name = resource_name
  @resources = resources
end

Instance Attribute Details

#resource_nameObject (readonly)

Returns the value of attribute resource_name.



11
12
13
# File 'lib/builderator/util/limit_exception.rb', line 11

def resource_name
  @resource_name
end

#resourcesObject (readonly)

Returns the value of attribute resources.



12
13
14
# File 'lib/builderator/util/limit_exception.rb', line 12

def resources
  @resources
end

Instance Method Details

#countObject



21
22
23
# File 'lib/builderator/util/limit_exception.rb', line 21

def count
  @resources.size
end

#limitObject



25
26
27
# File 'lib/builderator/util/limit_exception.rb', line 25

def limit
  Config.cleaner.limits[resource_name]
end

#messageObject



29
30
31
32
33
34
35
36
# File 'lib/builderator/util/limit_exception.rb', line 29

def message
  msg = "Safety limit exceeded for task `#{task}`: Count #{count} is "
  msg << "greater than the limit of #{limit} set in `cleaner.limits.#{resource_name}`. "
  msg << 'Please re-run this task with the --force flag if you are sure this is '\
  'the correct set of resources to delete.' unless Config.cleaner.force

  msg
end