predictype / predicates/errors / errorNamePattern
errorNamePattern(
source,oper,pattern):boolean
Defined in: predicates/errors/errorNamePattern.ts:25
Evaluates an error name against a pattern operation (matches or not matches a RegExp) using the specified operation.
Error
The Error whose name will be tested.
The pattern operation to perform (e.g. ‘matches’, ‘not_matches’).
RegExp
The RegExp to test against.
boolean
True if the operation matches, false otherwise.
If the operation is not recognized.
const err = new TypeError('boom');
errorNamePattern(err, 'matches', /Type/); // true
errorNamePattern(err, 'not_matches', /Range/); // true
Supported Operators: