Individual exception catching in promises in JavaScript

In then, you can specify only handler function of an exception by passing null instead of the first parameter:

javascriptpromise.then(
  null,
  function(error) {
    console.log(error);
  }
);

In this case, it is convenient to use a shortened syntax using the catch method:

javascriptpromise.catch(
  function(error) {
    console.log(error);
  }
);
Задание 1

Rewrite the following code via the catch method:

javascriptlet promise = new Promise(function(resolve, reject) {
  setTimeout(function() {
    let isError = false;
    
    if (!isError) {
      resolve('success');
    } else {
      reject(new Error('error'));
    }
  }, 3000);
});

promise.then(
  res => console.log(res),
  err => console.log(err.message),
);