predictype / predicates/errors / errorName
errorName(
source,oper,target):boolean
Defined in: predicates/errors/errorName.ts:28
Checks the name of an Error using the specified operation.
Error
The Error to check.
The name operation to perform (e.g. ‘equals’, ‘starts_with’).
string
The string to compare the error name against.
boolean
True if the name check is valid according to the operator, otherwise false.
If the operation is not recognized.
const err = new TypeError('boom');
errorName(err, 'equals', 'TypeError'); // true
errorName(err, 'ends_with', 'Error'); // true
errorName(err, 'equals', 'TypeError'); // true
Supported Operators: