Exception: Type::Error

Inherits:
TypeError
  • Object
show all
Defined in:
lib/type/error.rb

Overview

An Error class for exceptions raised while validating or casting

Direct Known Subclasses

CastError, ValidationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, type_definition) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
# File 'lib/type/error.rb', line 6

def initialize(input, type_definition)
  @input = input
  @type_definition = type_definition
  @cause = $! # aka $ERROR_INFO
end

Instance Attribute Details

#causeObject (readonly)

Returns the value of attribute cause.



16
17
18
# File 'lib/type/error.rb', line 16

def cause
  @cause
end

#inputObject (readonly)

Returns the value of attribute input.



16
17
18
# File 'lib/type/error.rb', line 16

def input
  @input
end

#type_definitionObject (readonly)

Returns the value of attribute type_definition.



16
17
18
# File 'lib/type/error.rb', line 16

def type_definition
  @type_definition
end

Instance Method Details

#to_sObject



12
13
14
# File 'lib/type/error.rb', line 12

def to_s
  "<#{self.class.name}: #{message}#{caused_by_clause}>"
end