Exception: Convertio::TypeMismatchError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/convertio.rb

Overview

Raise error if type mismatch

Instance Method Summary collapse

Constructor Details

#initialize(from_unit, to_unit) ⇒ TypeMismatchError

Returns a new instance of TypeMismatchError.



19
20
21
22
# File 'lib/convertio.rb', line 19

def initialize(from_unit, to_unit)
  error_message = "This conversion is not allowed: #{from_unit[:name]} is of type #{from_unit.fetch(:type)} but #{to_unit[:name]} is of type #{to_unit.fetch(:type)}" # rubocop:disable Layout/LineLength
  super(error_message)
end