title: MongoDB How to catch errors in deleteMany
body: <p>I have looked at MongoDB documentation for <code>deleteMany()</code> but it seems the only error it throws is <code>WriteConcernError</code>.</p>
  <p>I am using Insomnia to make my requests.</p>
  <p>Here is my request:</p>
  <pre><code>DELETE HTTP://localhost:5000/api/users/delete/usernames?usernames=[&quot;a&quot;,&quot;b&quot;,&quot;c&quot;]
  </code></pre>
  <p>As you can see I have an array in query string
  so I pass that to my function</p>
  <p>@ user.controller.js</p>
  <pre><code>function _deleteByUsernames(req, res, next) {
      userService.deleteByUsernames(JSON.parse(req.query.usernames))
          .then(() =&gt; res.status(200).json({&quot;message&quot;: &quot;User(s) successfully deleted!&quot;}))
          .catch(err =&gt; next(err));
  }
  </code></pre>
  <p>@  user.service.js</p>
  <pre><code>async function _deleteByUsernames(usernames) {
      try {
          console.log(usernames);
          await User.deleteMany({username: {$in: usernames}});
      } catch (err) {
          throw err;
      }
  }
  </code></pre>
  <p>I know there no documents with usernames <code>a</code>, <code>b</code> and <code>c</code>
  but <code>deleteMany()</code> doesn't return any error something like &quot;Coulnd't find given parameter&quot; etc.</p>
  <p>because I don't want to response with &quot;User(s) successfully deleted&quot;.
  How can I catch that error if there is one.
  Or How should I handle that?</p>