InvalidValue
Thrown to indicate that a variable has unexpected value.
- Source:
- InvalidValue.js, line 24
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 value
matches with the expected
values.
If it does, returns value
untouched. Otherwise, triggers
an exception.
The triggered exception holds value
and expected
as .info.checked
and .info.expected
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
any | A value to check |
|
expected |
any |
<repeatable> |
Expected value(s) |
- Source:
- InvalidValue.js, line 62
Returns:
the value
argument untouched if it has no problem
- Type:
- any
expects(value) → boolean
Returns true
if value
equals to or is included in info.expected
. Otherwise false
.
Recommended for using alongside of InvalidValue.check
method.
Parameters:
Name | Type | Description |
---|---|---|
value |
any | An expectation |
- Overrides:
- Exception#expects
- Source:
- InvalidValue.js, line 42
Returns:
- Type:
- boolean
Example
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