Exception: Operations::Errors::InvalidOperationError

Inherits:
BaseException
  • Object
show all
Defined in:
lib/operations/errors/invalid_operation_error.rb

Instance Method Summary collapse

Constructor Details

#initialize(operation, msg = nil) ⇒ InvalidOperationError

Returns a new instance of InvalidOperationError.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/operations/errors/invalid_operation_error.rb', line 4

def initialize(operation, msg=nil)
  if operation.class == Operations::Operation
    cause = "Cause:"
    has_cause = false
    unless operation.has_valid_name?
      cause += " invalid name"
      has_cause = true
    end
    unless operation.has_valid_scope?
      cause += " invalid scope `#{operation.invalid_scope}'"
      has_cause = true
    end
    cause "Unknown cause." unless has_cause
    message = "The operation #{operation} is not valid. #{cause}"
  else
    message = "Invalid operation object. Cause: `#{operation}'."
  end
  message += " Additional info: #{msg}" if msg
  super(message)
end