title: async and await and promise in regards to catching errors
body: <p>I have a question about catching user error in async and wait. </p>
  
  <p>Let say I have a route that only fetches for a single user. </p>
  
  <p>routes.js</p>
  
  <pre><code>routes.get('/getuserbyid/:id', (req, res) =&gt; {
  
      const id = req.params.id;
  
      accountController.getById(id)
          .then((result) =&gt; {
              res.json({
                  confirmation: 'success',
                  result: result
              });
          })
          .catch((error) =&gt; {
              res.json({
                  confirmation: 'failure',
                  error: error
              });
          });
  });
  </code></pre>
  
  <p>I have a controller that fetches the request.
  accountController.js </p>
  
  <pre><code>export const getById = async (id) =&gt; {
  
          try {
              const user = await users.findOne({ where: {
                      id: id
                  }});
  
              if (user === null) {
                  return 'User does not exist';
              }
              return user;
          } catch (error) {
              return error;
          }
  }
  </code></pre>
  
  <p>So no matter what happens either I get a null or a single record. It is still a success. 
  In promises, I can reject null, so it will show up in the catch block in the route. Now that with async and await. How can I achieve the same making the null in the error block?</p>
  
  <pre><code>export const getById = (id) =&gt; {
  
      return new Promise((resolve, reject) =&gt; {
  
          users.findOne({ where: {
              id: id
          }})
              .then((result) =&gt; {
  
                  if (result === null) {
                      reject('User does not exit');
                  }
                  resolve(result);
              })
              .catch((error) =&gt; {
                  reject(error);
              });
      });
  
  }
  </code></pre>