title: Cleancode: try/catch in Promise
body: <p>I am working on redux-form atm and found the piece of code. Its working for me but is there any cleaner way to write this in ES6 style?</p>
  
  <pre><code>const asyncValidate = (values/* , dispatch */) =&gt; {
    return new Promise((resolve, reject) =&gt; {
      try {
        if (['john', 'paul', 'george', 'ringo'].includes(values.name)) {
          const error = {
            name: 'That username is taken'
          };
          throw error;
        }
        resolve();
      } catch (e) {
        reject(e);
      }
    });
  };
  </code></pre>
  
  <p>I would appreciate your help</p>
  
  <hr>
  
  <h2>Solution</h2>
  
  <pre><code>const asyncValidate = (values/* , dispatch */) =&gt; {
    return new Promise((resolve, reject) =&gt; {
      const errors = {};
      if (['john', 'paul', 'george', 'ringo'].includes(values.name)) {
        errors.name = 'That username is taken';
      }
      reject(errors);
    });
  };
  </code></pre>
  
  <p>probably cleaner way?!</p>