predictype / predicates/errors / errorMessagePattern
errorMessagePattern(
source,oper,pattern):boolean
Defined in: predicates/errors/errorMessagePattern.ts:25
Evaluates an error message against a pattern operation (matches or not matches a RegExp) using the specified operation.
Error
The Error whose message 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 Error('Network timeout');
errorMessagePattern(err, 'matches', /timeout$/); // true
errorMessagePattern(err, 'not_matches', /syntax/i); // true
Supported Operators: