Exception: Eddy::Errors::ElementValidationError

Inherits:
Error
  • Object
show all
Defined in:
lib/eddy/errors.rb

Overview

Exception raised by descendents of Models::Element::Base.

Element Validation Errors collapse

Element Validation Errors collapse

Constructor Details

#initialize(msg = "", element: nil) ⇒ void

Parameters:

  • msg (String) (defaults to: "")

    ("")

  • element (Eddy::Models::Element::Base) (defaults to: nil)

    (nil) Element instance that raised the exception.



20
21
22
23
24
# File 'lib/eddy/errors.rb', line 20

def initialize(msg = "", element: nil)
  self.element = element unless element.nil?
  msg = "Invalid value assigned to element #{element_description()}. " << msg
  super(msg)
end

Instance Attribute Details

#argObject

Argument that caused the exception when passed to value=. (if applicable)

Returns:

  • (Object)


15
16
17
# File 'lib/eddy/errors.rb', line 15

def arg
  @arg
end

#elementEddy::Models::Element::Base

Returns Element instance that raised the exception.

Returns:



12
13
14
# File 'lib/eddy/errors.rb', line 12

def element
  @element
end

Instance Method Details

#element_descriptionString

Returns:

  • (String)


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/eddy/errors.rb', line 27

def element_description()
  el = self.element
  return "" if el.nil?
  description = ""
  if !el.ref.nil? && el.ref.length > 0
    description << el.ref
  else
    description << el.class.name.split("::").last
  end
  description << " (#{el.name})"
  return description
end