title: Is it possible to trap CORS errors?
body: <p>This question is related to Cross-Origin Resource Sharing (CORS, <a href="http://www.w3.org/TR/cors/" rel="noreferrer">http://www.w3.org/TR/cors/</a>).  </p>
  
  <p>If there is an error when making a CORS request, Chrome (and AFAIK other browsers as well) logs an error to the error console.  An example message may look like this: </p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <code>http://domain2.example</code>. Origin <code>http://domain1.example</code> is not allowed by Access-Control-Allow-Origin.</p>
  </blockquote>
  
  <p>I'm wondering if there's a way to programmatically get this error message?  I've tried wrapping my <code>xhr.send()</code> call in try/catch, I've also tried adding an <code>onerror()</code> event handler.  Neither of which receives the error message.</p>