class Dalton::TypeError
Constants
- MESSAGE_RE
Attributes
attribute[R]
message[R]
type[R]
value[R]
Public Class Methods
new(opts={})
click to toggle source
# File lib/dalton/exception.rb, line 53 def initialize(opts={}) @value = opts.fetch(:value) @type = opts.fetch(:type) @attribute = opts.fetch(:attribute) @message = "Type error: tried to set #@attribute as #@value, expected type #@type" end
parse(message)
click to toggle source
# File lib/dalton/exception.rb, line 41 def self.parse(message) message =~ MESSAGE_RE raise ArgumentError, "invalid format: #{message.inspect}" unless $~ new( value: $1, type: $2.to_sym, attribute: $3.to_sym ) end
Public Instance Methods
inspect()
click to toggle source
# File lib/dalton/exception.rb, line 64 def inspect "#<#{self.class.name}: @attribute=#@attribute @value=#@value @type=#@type>" end
to_s()
click to toggle source
# File lib/dalton/exception.rb, line 60 def to_s "#{self.class.name}: #@message" end