DEV Community

Discussion on: Better error handling with async/await

Collapse
 
4n0nym0u5n1nj4 profile image
4n0nym0u5n1nj4 • Edited

why you put Promise.resolve in catch function?

const handle = (promise) => {
  return promise
    .then(data => ([data, undefined]))
    .catch(error => ([undefined, error]));
}

is ok.

Collapse
 
samartuso profile image
Sam Artuso

I agree, there's no reason for putting Promise.resolve in the catch().