title: Throwing an error in node.js
body: <p>I've got a tiny module that acts as a model for my data. It sits between my routes and my database for particular data (user data in my case).</p>
  
  <p>I require this module in my route code, call the <code>subscribe</code> method that it has, and that subscribes a user to a particular mailing list, by storing the needed data in my database. Yay! </p>
  
  <p>My 'subscribe' method accepts an email and an email list ID as the two parameters. It's reasonable that I'll code sloppy and fast and put in an id for a list that doesn't exist. Spelling error, you name it.</p>
  
  <p>How can I throw an error and point to the line number with that incorrect id?</p>
  
  <p>Code from inside model/user.js:</p>
  
  <pre><code>if (emailLists.indexOf(listId) === -1) {
    throw new Error('listId does not exist');
  }
  </code></pre>
  
  <p>Code from inside route.js:</p>
  
  <pre><code>user.subscribe('fake@email.com', 'knewsletterr', function (error, success) {
    if (error) { return sendResponse(500, 'Ahhhhhhh!'); }
    if (!error) { return sendResponse(200, 'subscribed'); }
  });
  </code></pre>
  
  <p>Right now, I'm getting:</p>
  
  <pre><code>/home/.../project/models/user.js:85
  if (emailLists.indexOf(listId) === -1) { throw new Error('listId does not exist'); }
                                                     ^
  Error: listId does not exist
  </code></pre>