class Garcon::Exceptions::ValidationError

Attributes

type[RW]
value[RW]

Public Class Methods

new(value, type = nil) click to toggle source
Calls superclass method
# File lib/garcon/exceptions.rb, line 36
def initialize(value, type = nil)
  @value, @type = value, type
  super(build_message)
  super(detail)
end

Public Instance Methods

build_message() click to toggle source
# File lib/garcon/exceptions.rb, line 42
def build_message
  if type?
    "#{value} is not a valid #{type}"
  else
    "Failed to validate #{value.inspect}"
  end
end
detail() click to toggle source

Pretty string output of exception/error object useful for helpful debug messages.

# File lib/garcon/exceptions.rb, line 57
def detail
  if backtrace
    %{#{self.class.name}: #{message}\n  #{backtrace.join("\n  ")}\n  LOGGED FROM: #{caller[0]}}
  else
    %{#{self.class.name}: #{message}\n  LOGGED FROM: #{caller[0]}}
  end
end
type?() click to toggle source
# File lib/garcon/exceptions.rb, line 50
def type?
  type.nil? ? false : true
end