Confuse about error and reject in Promise
<p>All:</p>

<p>I am pretty new to JS Promise, there is one confuse when it comes to Promise chaining, say I have a promise chaining like:</p>

<pre><code>var p = new Promise(function(res, rej){
})
.then(
    function(data){
    }, 
    function(err){
    })
.then(
    function(data){
    }, 
    function(err){
    })
.catch(
    function(err){
    })
</code></pre>

<p>What confuse me:</p>

<ol>
<li>When the function(err) get called and when the catch get called?</li>
<li>How to resolve and reject in <code>then</code>?</li>
</ol>

<p>Thanks</p>