Exception(msgopt, infoopt, hidesInfoopt)
The base class of all the other exceptions.
Constructor
new Exception(msgopt, infoopt, hidesInfoopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
msg |
string |
<optional> |
null | Message |
info |
any |
<optional> |
null | Additional information for debug |
hidesInfo |
boolean |
<optional> |
false | Whether or not to hide |
- Source:
- Exception.js, line 7
Extends
ErrorMembers
staticreadonlymessage string
The default message for this exception class.
- Source:
- Exception.js, line 31
readonlyinfo any
Additional informations for debug.
- Source:
- Exception.js, line 23
Methods
abstractstaticcheck(value) → any
Checks whether value
meets the expected condition varied by each subclass.
Parameters:
Name | Type | Description |
---|---|---|
value |
any | A value to check |
- Source:
- Exception.js, line 100
Returns:
the value
argument untouched if there's no problem. Otherwise triggers the exception.
- Type:
- any
staticoption(name, valueopt) → anyclass
Returns the value of the option specified by name
.
If value
is provided, assigns the value to the option instead of returning it.
You can customize the default behavior of Exception
at some level by changing the option values.
Available options:
Name | Type | Description |
---|---|---|
handler |
function | Runs when trigger() is called. Receives the triggered exception instance as the argument |
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | Option name |
|
value |
any |
<optional> |
Option value to set |
- Source:
- Exception.js, line 78
Returns:
The option value, or this exception class if value
is provided
- Type:
- any | class
staticoptions(setopt) → objectclass
If set
is not provided, returns all the current option values in a plain object form.
If set
is provided, assigns each value in set
to the option corresponding with the key.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
set |
object |
<optional> |
Multiple key-value pairs |
- Source:
- Exception.js, line 89
Returns:
The current options in a plain object form, or this exception class if set
is provided
- Type:
- object | class
staticreset() → class
Resets all the options to the default values.
- Source:
- Exception.js, line 58
Returns:
This exception class
- Type:
- class
abstractexpects(value) → boolean
Returns whether this exception has expected value
specifically.
Parameters:
Name | Type | Description |
---|---|---|
value |
any | An expectation |
- Source:
- Exception.js, line 51
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.
- Source:
- Exception.js, line 41
- See:
- Exception.option
Throws:
This exception
Returns:
The result of option.handler
function
- Type:
- any