Exception: Garcon::Exceptions::ValidationError
- Defined in:
- lib/garcon/exceptions.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #build_message ⇒ Object
-
#detail ⇒ Object
Pretty string output of exception/error object useful for helpful debug messages.
-
#initialize(value, type = nil) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #type? ⇒ Boolean
Constructor Details
#initialize(value, type = nil) ⇒ ValidationError
Returns a new instance of ValidationError.
36 37 38 39 40 |
# File 'lib/garcon/exceptions.rb', line 36 def initialize(value, type = nil) @value, @type = value, type super() super(detail) end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
34 35 36 |
# File 'lib/garcon/exceptions.rb', line 34 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
34 35 36 |
# File 'lib/garcon/exceptions.rb', line 34 def value @value end |
Instance Method Details
#build_message ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/garcon/exceptions.rb', line 42 def if type? "#{value} is not a valid #{type}" else "Failed to validate #{value.inspect}" end end |
#detail ⇒ Object
Pretty string output of exception/error object useful for helpful debug messages.
57 58 59 60 61 62 63 |
# File 'lib/garcon/exceptions.rb', line 57 def detail if backtrace %{#{self.class.name}: #{}\n #{backtrace.join("\n ")}\n LOGGED FROM: #{caller[0]}} else %{#{self.class.name}: #{}\n LOGGED FROM: #{caller[0]}} end end |
#type? ⇒ Boolean
50 51 52 |
# File 'lib/garcon/exceptions.rb', line 50 def type? type.nil? ? false : true end |