title: try..catch errors in mongo shell
body: <p>I am trying to automate mongodb setup and create users via a js script in mongo shell.</p>
  
  <p>i tried to create the admin user and i want to check if the user is already created. If i run create user if the user already exists, it throws error. SO i want to check if the user is there already</p>
  
  <pre><code>#init.js
  use admin
  try {
  db.createUser({
  "user":"admin",
  "pwd":"paddowrd",
  "roles":[{"role":"root", "db":"admin"}]
  });
  }
  catch (err) {
  print ("Admin user already created");
  db.auth("admin","paddowrd");
  }
  
  
  
  
  mongo &lt; init.js
  </code></pre>
  
  <p>output:[error]</p>
  
  <p>2019-06-06T14:07:58.039+0000 E QUERY [js] SyntaxError: missing catch or finally after try @(shell):2:0</p>