predictype

predictype v0.13.0


predictype / predicates/errors / errorState

Function: errorState()

errorState(source, oper): boolean

Defined in: predicates/errors/errorState.ts:26

Checks the state of an Error using the specified operation.

Parameters

source

Error

The Error to check.

oper

ErrorStateOper

The state operation to perform (e.g. ‘has_stack’, ‘has_cause’).

Returns

boolean

True if the state check is valid according to the operator, otherwise false.

Throws

If the operation is not recognized.

Example

const err = new Error('boom');

errorState(err, 'has_stack'); // true
errorState(new AggregateError([], 'many'), 'is_aggregate_error'); // true

Remarks

Supported Operators: