Invokes a user-supplied error handler without letting it throw.
A handler that fails while reporting a failure would replace the original error with its
own — the classic way to lose the interesting one. Here both are logged and neither
escapes. A missing or non-function handler is a no-op, so callers need no guard.
Parameters
handler: ((err:unknown)=>void) |undefined
Optional callback; anything that is not a function is ignored.
Invokes a user-supplied error handler without letting it throw.
A handler that fails while reporting a failure would replace the original error with its own — the classic way to lose the interesting one. Here both are logged and neither escapes. A missing or non-function handler is a no-op, so callers need no guard.