Class: GuardError
Class to handle errors which are triggered by data guards.
Extends
Constructors
Constructor
new GuardError(
source,message,propertyName,propertyValue,propertyOptions?):GuardError
Create a new instance of GuardError.
Parameters
source
string
The source of the error.
message
string
The message as a code.
propertyName
string
The property which triggered the guard error for the item.
propertyValue
unknown
The property value which triggered the guard error for the item.
propertyOptions?
string
The property options which might be allowed.
Returns
GuardError
Overrides
Properties
source?
optionalsource:string
The source of the error.
Inherited from
properties?
optionalproperties:object
Any additional information for the error.
Index Signature
[id: string]: unknown
Inherited from
cause?
optionalcause:IError
The cause of the error.
Inherited from
CLASS_NAME
readonlystaticCLASS_NAME:string
Runtime name for the class.
Methods
fromError()
staticfromError(err):BaseError
Construct an error from an existing one.
Parameters
err
unknown
The existing error.
Returns
The new instance.
Inherited from
flatten()
staticflatten(err):IError[]
Flatten an error tree.
Parameters
err
unknown
The starting error.
Returns
IError[]
The list of all internal errors.
Inherited from
expand()
staticexpand(errors):undefined|IError
Expand an error tree.
Parameters
errors
The list of errors to expand.
undefined | IError[]
Returns
undefined | IError
The first level error.
Inherited from
isErrorName()
staticisErrorName(error,name):error is BaseError
Test to see if the error has the specified error name.
Parameters
error
unknown
The error to test.
name
The name to check for.
string | RegExp
Returns
error is BaseError
True if the error has the name.
Inherited from
isErrorMessage()
staticisErrorMessage(error,message):error is BaseError
Test to see if the error has the specified error message.
Parameters
error
unknown
The error to test.
message
The message to check for.
string | RegExp
Returns
error is BaseError
True if the error has the name.
Inherited from
isErrorCode()
staticisErrorCode(error,code):boolean
Test to see if the error has the specified error code.
Parameters
error
unknown
The error to test.
code
The code to check for.
string | RegExp
Returns
boolean
True if the error has the code.
Inherited from
someErrorName()
staticsomeErrorName(error,name):error is BaseError
Test to see if any of the errors or children have the given error name.
Parameters
error
unknown
The error to test.
name
The name to check for.
string | RegExp
Returns
error is BaseError
True if the error has the name.
Inherited from
someErrorMessage()
staticsomeErrorMessage(error,message):error is BaseError
Test to see if any of the errors or children have the given error message.
Parameters
error
unknown
The error to test.
message
The message to check for.
string | RegExp
Returns
error is BaseError
True if the error has the name.
Inherited from
someErrorClass()
staticsomeErrorClass(error,cls):error is BaseError
Test to see if any of the errors or children are from a specific class.
Parameters
error
unknown
The error to test.
cls
string
The class to check for.
Returns
error is BaseError
True if the error has the specific class.
Inherited from
someErrorCode()
staticsomeErrorCode(error,code):error is BaseError
Test to see if any of the errors or children have the given error code.
Parameters
error
unknown
The error to test.
code
The code to check for.
string | RegExp
Returns
error is BaseError
True if the error has the name.
Inherited from
isEmpty()
staticisEmpty(err):boolean
Is the error empty, i.e. does it have no message, source, properties, or cause?
Parameters
err
The error to check for being empty.
Returns
boolean
True if the error is empty.
Inherited from
isAggregateError()
staticisAggregateError(err):err is AggregateError
Is the error an aggregate error.
Parameters
err
unknown
The error to check for being an aggregate error.
Returns
err is AggregateError
True if the error is an aggregate error.
Inherited from
fromAggregate()
staticfromAggregate(err,includeStackTrace?):IError[]
Convert the aggregate error to an array of errors.
Parameters
err
unknown
The error to convert.
includeStackTrace?
boolean
Whether to include the error stack in the model, defaults to false.
Returns
IError[]
The array of errors.
Inherited from
toJsonObject()
toJsonObject(
includeStackTrace?):IError
Serialize the error to the error model.
Parameters
includeStackTrace?
boolean
Whether to include the error stack in the model, defaults to false.
Returns
The error model.