Skip to content

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.

unknown

The value to test.

boolean

true if error is a SerializedError produced by serializeError; otherwise false.

const original = new Error('oops');
const serialized = serializeError(original);
console.log(isSerializedError(original)); // → false
console.log(isSerializedError(serialized)); // → true
// Plain objects without the internal marker return false
console.log(isSerializedError({ type: 'Error', message: 'oops' })); // → false