Contains error codes, factory functions to create throwable error objects,
and warning/deprecation functions.
Members
(inner) constants
When Mocha throw exceptions (or otherwise errors), it attempts to assign a
code
property to the Error
object, for easier handling. These are the
potential values of code
.
Methods
(inner) createFatalError(message) → {Error}
Creates an error object to be thrown when an unrecoverable error occurs.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Error message to be displayed. |
Returns:
instance detailing the error condition
- Type
- Error
(inner) createForbiddenExclusivityError(mocha) → {Error}
Creates an error object to be thrown when .only()
is used with
--forbid-only
.
Parameters:
Name | Type | Description |
---|---|---|
mocha |
Mocha | Mocha instance |
Returns:
Error with code constants.FORBIDDEN_EXCLUSIVITY
- Type
- Error
(inner) createInvalidArgumentTypeError(message, argument, expected) → {Error}
Creates an error object to be thrown when an argument did not use the supported type
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Error message to be displayed. |
argument |
string | Argument name. |
expected |
string | Expected argument datatype. |
Returns:
instance detailing the error condition
- Type
- Error
(inner) createInvalidArgumentValueError(message, argument, value, reasonopt) → {Error}
Creates an error object to be thrown when an argument did not use the supported value
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | Error message to be displayed. |
|
argument |
string | Argument name. |
|
value |
string | Argument value. |
|
reason |
string |
<optional> |
Why value is invalid. |
Returns:
instance detailing the error condition
- Type
- Error
(inner) createInvalidExceptionError(message) → {Error}
Creates an error object to be thrown when an exception was caught, but the Error
is falsy or undefined.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Error message to be displayed. |
Returns:
instance detailing the error condition
- Type
- Error
(inner) createInvalidInterfaceError(message, ui) → {Error}
Creates an error object to be thrown when the interface specified in the options was not found.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Error message to be displayed. |
ui |
string | User-specified interface value. |
Returns:
instance detailing the error condition
- Type
- Error
(inner) createInvalidLegacyPluginError(message, pluginType, pluginIdopt) → {Error}
Dynamically creates a plugin-type-specific error based on plugin type
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | Error message |
|
pluginType |
"reporter" | "interface" | Plugin type. Future: expand as needed |
|
pluginId |
string |
<optional> |
Name/path of plugin, if any |
Throws:
When pluginType
is not known
Returns:
- Type
- Error
(inner) createInvalidPluginDefinitionError(msg, pluginDefopt) → {Error}
Creates an error object to be thrown when a plugin definition is invalid
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
msg |
string | Error message |
|
pluginDef |
PluginDefinition |
<optional> |
Problematic plugin definition |
Returns:
Error with code constants.INVALID_PLUGIN_DEFINITION
- Type
- Error
(inner) createInvalidPluginError(message, pluginType, pluginIdopt) → {Error}
DEPRECATED. Use createInvalidLegacyPluginError instead Dynamically creates a plugin-type-specific error based on plugin type
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message |
string | Error message |
|
pluginType |
"reporter" | "interface" | Plugin type. Future: expand as needed |
|
pluginId |
string |
<optional> |
Name/path of plugin, if any |
Throws:
When pluginType
is not known
Returns:
- Type
- Error
(inner) createInvalidPluginImplementationError(msg, optsopt) → {Error}
Creates an error object to be thrown when a plugin implementation (user code) is invalid
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
msg |
string | Error message |
|||||||||||||
opts |
Object |
<optional> |
Plugin definition and user-supplied implementation Properties
|
Returns:
Error with code constants.INVALID_PLUGIN_DEFINITION
- Type
- Error
(inner) createInvalidReporterError(message, reporter) → {Error}
Creates an error object to be thrown when the reporter specified in the options was not found.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Error message to be displayed. |
reporter |
string | User-specified reporter value. |
Returns:
instance detailing the error condition
- Type
- Error
(inner) createMissingArgumentError(message, argument, expected) → {Error}
Creates an error object to be thrown when an argument is missing.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Error message to be displayed. |
argument |
string | Argument name. |
expected |
string | Expected argument datatype. |
Returns:
instance detailing the error condition
- Type
- Error
(inner) createMochaInstanceAlreadyDisposedError(message, cleanReferencesAfterRun, instance)
Creates an error object to be thrown when a mocha object's run
method is executed while it is already disposed.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | The error message to be displayed. |
cleanReferencesAfterRun |
boolean | the value of |
instance |
Mocha | the mocha instance that throw this error |
(inner) createMochaInstanceAlreadyRunningError(message)
Creates an error object to be thrown when a mocha object's run
method is called while a test run is in progress.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | The error message to be displayed. |
(inner) createNoFilesMatchPatternError(message, pattern) → {Error}
Creates an error object to be thrown when no files to be tested could be found using specified pattern.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Error message to be displayed. |
pattern |
string | User-specified argument value. |
Returns:
instance detailing the error condition
- Type
- Error
(inner) createUnsupportedError(message) → {Error}
Creates an error object to be thrown when a behavior, option, or parameter is unsupported.
Parameters:
Name | Type | Description |
---|---|---|
message |
string | Error message to be displayed. |
Returns:
instance detailing the error condition
- Type
- Error