InvalidType
Thrown to indicate that the type of a value isn't expected.
- Source:
- InvalidType.js, line 40
Examples
Extends
ExceptionMembers
readonlyinfo any
Additional informations for debug.
- Inherited From:
- Exception#info
- Source:
- Exception.js, line 23
Methods
staticcheck(value, …expected) → any
Checks if the type of value
matches with expected
. If it does, just returns value
.
Otherwise, triggers
an exception.
The triggered exception holds value
and expected
as .info.checked
and .info.expected
.
And the actual type is stored in .info.actual
.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
any | A value to check the type |
|||||||||||||
expected |
string | class |
<repeatable> |
The expected type(s) Available Types
|
- Source:
- InvalidType.js, line 77
Returns:
Just returns the value
argument if there's no problem
- Type:
- any
expects(type) → boolean
Returns if this exception expected type
.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | class |
- Overrides:
- Exception#expects
- Source:
- InvalidType.js, line 47
- See:
- InvalidType.check
Returns:
- Type:
- boolean
trigger() → any
Throws this exception if handler
option is not set.
If handler
option is set, calls it and returns the result.
- Inherited From:
- Exception#trigger
- Source:
- Exception.js, line 41
- See:
- Exception.option
Throws:
This exception
Returns:
The result of option.handler
function
- Type:
- any