Exception: Common::InvalidActionSequence
- Inherits:
-
InvalidRequest
- Object
- StandardError
- CloudboxError
- InvalidRequest
- Common::InvalidActionSequence
- Defined in:
- lib/common/cloudbox_exceptions.rb
Overview
Get a message if an action is invalid.
Instance Method Summary collapse
-
#getAction ⇒ Object
Get an action.
-
#getCurrentState ⇒ Object
Get the current state.
-
#getEntityName ⇒ Object
Get the entity name.
-
#getEntityType ⇒ Object
Get the entity type.
-
#getMsg ⇒ Object
private
Get the message of the error.
-
#initialize(action, currentState, possibilities, entityName, entityType) ⇒ InvalidActionSequence
constructor
Default constructor of the class.
Constructor Details
#initialize(action, currentState, possibilities, entityName, entityType) ⇒ InvalidActionSequence
Note:
Overrides default constructor by passing CustomCommandOption to super().
Default constructor of the class.
420 421 422 423 424 425 426 427 |
# File 'lib/common/cloudbox_exceptions.rb', line 420 def initialize(action, currentState, possibilities, entityName, entityType) @action = action @currentState = currentState @entityName = entityName @entityType = entityType @possibilities = possibilities super(getMsg()) end |
Instance Method Details
#getAction ⇒ Object
Get an action
430 431 432 |
# File 'lib/common/cloudbox_exceptions.rb', line 430 def getAction return @action end |
#getCurrentState ⇒ Object
Get the current state
435 436 437 |
# File 'lib/common/cloudbox_exceptions.rb', line 435 def getCurrentState return @currentState end |
#getEntityName ⇒ Object
Get the entity name
440 441 442 |
# File 'lib/common/cloudbox_exceptions.rb', line 440 def getEntityName return @entityName end |
#getEntityType ⇒ Object
Get the entity type
445 446 447 |
# File 'lib/common/cloudbox_exceptions.rb', line 445 def getEntityType return @entityType end |
#getMsg ⇒ Object (private)
Get the message of the error
451 452 453 454 455 456 457 458 459 460 |
# File 'lib/common/cloudbox_exceptions.rb', line 451 def getMsg() sexyStates = "" first = true @possibilities[@action]['required_state'].each do |a| sexyStates += "|" unless first first = false sexyStates += a end msg = "To #{@action} the #{@entityType} #{@entityName}, it has to be in state #{sexyStates} (current: '#{@currentState}')." end |