Exception: Builderator::Util::LimitException
- Inherits:
-
TaskException
- Object
- StandardError
- TaskException
- Builderator::Util::LimitException
- 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
-
#resource_name ⇒ Object
readonly
Returns the value of attribute resource_name.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Attributes inherited from TaskException
Instance Method Summary collapse
- #count ⇒ Object
-
#initialize(resource_name, task, resources) ⇒ LimitException
constructor
A new instance of LimitException.
- #limit ⇒ Object
- #message ⇒ Object
Methods inherited from TaskException
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_name ⇒ Object (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 |
#resources ⇒ Object (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
#count ⇒ Object
21 22 23 |
# File 'lib/builderator/util/limit_exception.rb', line 21 def count @resources.size end |
#limit ⇒ Object
25 26 27 |
# File 'lib/builderator/util/limit_exception.rb', line 25 def limit Config.cleaner.limits[resource_name] end |
#message ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/builderator/util/limit_exception.rb', line 29 def 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 |