isSerializedError
isSerializedError(
error
):boolean
Type-guard to detect whether a value has been serialized into a SerializedError
by serializeError
. Internally marks serialized errors with a hidden symbol.
Parameters
Section titled “Parameters”unknown
The value to test.
Returns
Section titled “Returns”boolean
true
if error
is a SerializedError
produced by serializeError
; otherwise false
.
Examples
Section titled “Examples”const original = new Error('oops');const serialized = serializeError(original);
console.log(isSerializedError(original)); // → falseconsole.log(isSerializedError(serialized)); // → true
// Plain objects without the internal marker return falseconsole.log(isSerializedError({ type: 'Error', message: 'oops' })); // → false