Contains error codes, factory functions to create throwable error objects,
and warning/deprecation functions.
Namespaces
Methods
(static) 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
(static) 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
(static) 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
(static) 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
(static) 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
(static) 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
(static) 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" | "ui" | Plugin type. Future: expand as needed | |
pluginId | string | <optional> | Name/path of plugin, if any |
Throws:
When pluginType
is not known
Returns:
- Type
- Error
(static) 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
(static) 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
(static) 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
(static) 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
(static) 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 |
(static) 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. |
(static) createMultipleDoneError(runnable, originalErropt) → {Error}
Creates an error object to be thrown when done() is called multiple times in a test
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
runnable | Runnable | Original runnable | |
originalErr | Error | <optional> | Original error, if any |
Returns:
instance detailing the error condition
- Type
- Error
(static) 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
(static) createTimeoutError(msg, timeoutopt, fileopt) → {MochaTimeoutError}
Creates an error object to be thrown when a runnable exceeds its allowed run time.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
msg | string | Error message | |
timeout | number | <optional> | Timeout in ms |
file | string | <optional> | File, if given |
Returns:
(static) createUnparsableFileError(message, filename) → {Error}
Creates an error object to be thrown when file is unparsable
Parameters:
Name | Type | Description |
---|---|---|
message | string | Error message to be displayed. |
filename | string | File name |
Returns:
Error with code constants.UNPARSABLE_FILE
- Type
- Error
(static) 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
(static) isMochaError(err) → {boolean}
Returns true
if an error came out of Mocha.
Can suffer from false negatives, but not false positives.
Parameters:
Name | Type | Description |
---|---|---|
err | * | Error, or anything |
Returns:
- Type
- boolean
(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
Type Definitions
MochaTimeoutError
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
code | constants.TIMEOUT | Error code | |
timeout | number | <nullable> | Timeout in ms |
file | string | <nullable> | Filepath, if given |
The error thrown when a Runnable times out
Type:
- Error