const controlFn = () => {
const shouldError = Math.random() > 0.5
if (shouldError)
throw new Error('An error occured')
return 123
}
const fn = () => {
const shouldError = Math.random() > 0.5
if (shouldError)
return [undefined, new Error('An error occured')]
return [123]
}let result
let err
try {
result = fn()
}
catch (e) {
err = e
}const [result2, err2] = fn()