class Hashie::CoercionError

@example Describe a failed conversion

require 'hashie/extensions/coercion'
error = Hashie::CoercionError.new(:age, 'bad', Integer, 'invalid number')
error.message # => 'cannot coerce property `:age` from `String` to `Integer`: invalid number'

Public Class Methods

new(key, value, into, message) click to toggle source

@example Include the key, source class, and destination in the message

require 'hashie/extensions/coercion'
error = Hashie::CoercionError.new(:age, 'bad', Integer, 'invalid number')
error.message # => 'cannot coerce property `:age` from `String` to `Integer`: invalid number'
Calls superclass method
# File lib/hashie/extensions/coercion.rb, line 13
def initialize(key, value, into, message)
  super("cannot coerce property `#{key.inspect}` from `#{value.class}` to `#{into}`: #{message}")
end