API reference › @evolu/common › Error › createUnknownError
function createUnknownError(error: unknown): UnknownError;
Defined in: packages/common/src/Error.ts:48
Creates an UnknownError from an unknown error.
An Error becomes a plain object of its own properties, such as message
and stack, plus its name, message, and stack when they are inherited,
as in a DOMException. A property that is an Error, such as cause, is
converted the same way, an array, such as the errors of an
AggregateError, is converted element by element, a function is dropped, and
any other property is kept when it can be structured-cloned, or described as
a string when it cannot. Reference cycles through errors and arrays stay
cycles in the result. An Error's properties are not enumerable, so JSON and
comparisons by content miss them, and a structured clone creates a new
Error. Any other value is structured-cloned, or described by String when
it cannot be, or as "[Unserializable Object]" when even that throws.