View Source TypeCheck.TypeError exception (TypeCheck v0.13.7)
Exception to be returned or raised when a value is not of the expected type.
This exception has two fields:
:raw
, which will contain the problem tuple of the type check failure.:message
, which will contain a the humanly-readable representation of the raw problem_tuple
:message
is constructed from :raw
using the TypeCheck.TypeError.DefaultFormatter.
(TODO at some point this might be configured to use your custom formatter instead)
Summary
Types
The name of the particular check. Might be :no_match
for simple types,
but for more complex types that have multiple checks, it disambugates between them.
An extra map with any information related to the check that failed.
A problem_tuple contains all information about a failed type check.
The value that was passed in which failed the check.
Any built-in TypeCheck struct (c.f. TypeCheck.Builtin.*
), whose check(s) failed.
Types
@type check_name() :: atom()
The name of the particular check. Might be :no_match
for simple types,
but for more complex types that have multiple checks, it disambugates between them.
For instance, for TypeCheck.Builtin.List
we have :not_a_list
, :different_length
, and :element_error
.
An extra map with any information related to the check that failed.
For instance, if the check was a compound check, will contain the field problem:
with the child problemtuple
as well as :index
or :key
etc. to indicate _where in the compound structure the check failed.
@type location() :: [] | [file: binary(), line: non_neg_integer()]
@type problem_tuple() :: {type_checked_against(), check_name(), extra_information(), problematic_value()}
A problem_tuple contains all information about a failed type check.
c.f. TypeCheck.TypeError.Formatter.problem_tuple for a more precise definition
@type problematic_value() :: any()
The value that was passed in which failed the check.
It is included for the easy creation of value did not match y
-style messages.
@type t() :: %TypeCheck.TypeError{ __exception__: true, location: location(), message: String.t(), raw: problem_tuple() }
@type type_checked_against() :: TypeCheck.Type.t()
Any built-in TypeCheck struct (c.f. TypeCheck.Builtin.*
), whose check(s) failed.