Ensures we have a proper Error object.
If the input is already an Error, returns it unchanged.
Otherwise, converts to an Error with an appropriate message and preserves
the original value as the cause.
Returns
A proper Error instance.
Parameters
error: unknown
The caught error (could be Error, string, or unknown).
Ensures we have a proper Error object. If the input is already an Error, returns it unchanged. Otherwise, converts to an Error with an appropriate message and preserves the original value as the cause.
Returns
A proper Error instance.