Run the supplied arity-zero function, and if it throws an error, return the
caughtValue instead (or undefined if not provided).
This is only safe to do when we know that nothing at any point in the call
stack relies on the Error.stack property, and only worth doing in hot
paths where a function is expected to throw often (for example, calling
statSync on many paths to find the first one that exists).
Run the supplied arity-zero function, and if it throws an error, return the
caughtValue
instead (orundefined
if not provided).This is only safe to do when we know that nothing at any point in the call stack relies on the
Error.stack
property, and only worth doing in hot paths where a function is expected to throw often (for example, callingstatSync
on many paths to find the first one that exists).