title: Catching errors generated in Promises within Promises in JavaScript
body: <p>Is it possible to have errors bubble up in Promises?</p>
  
  <p>See the code below for reference, I'd like to get <code>promise1.catch</code> to catch the error generated in <code>promise2</code> (which current does not work with this code):</p>
  
  <pre><code>function test() {
      var promise1 = new Promise(function(resolve1) {
          var promise2 = new Promise(function(resolve2) {
              throw new Error('Error in promise2!');
          });
  
          promise2.catch(function(error2) {
              console.log('Caught at error2', error2);
          });
      });
  
      promise1.catch(function(error1) {
          console.log('Caught at error1', error1);
      });
  }
  
  test();
  </code></pre>