<h1 dir="auto">problem statement</h1>
<ul dir="auto">
<li>node barks with warnings on every rejected 400/500 axios call</li>
</ul>
<p dir="auto">specficically, it complains with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Warning: a promise was rejected with a non-error: [object Object]
    at IncomingMessage.handleStreamEnd (/path/to/my/pkg//node_modules/axios/lib/adapters/http.js:112:16)
    at emitNone (events.js:85:20)
    at IncomingMessage.emit (events.js:179:7)
    at endReadableNT (_stream_readable.js:913:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)"><pre class="notranslate"><code class="notranslate">Warning: a promise was rejected with a non-error: [object Object]
    at IncomingMessage.handleStreamEnd (/path/to/my/pkg//node_modules/axios/lib/adapters/http.js:112:16)
    at emitNone (events.js:85:20)
    at IncomingMessage.emit (events.js:179:7)
    at endReadableNT (_stream_readable.js:913:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
</code></pre></div>
<h1 dir="auto">supplmental context</h1>
<p dir="auto">see reference in where this happens:</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// axios/lib/adapters/http.js
      (res.statusCode &gt;= 200 &amp;&amp; res.statusCode &lt; 300 ?
        resolve :
        reject)(response);"><pre class="notranslate"><span class="pl-c">// axios/lib/adapters/http.js</span>
      <span class="pl-kos">(</span><span class="pl-s1">res</span><span class="pl-kos">.</span><span class="pl-c1">statusCode</span> <span class="pl-c1">&gt;=</span> <span class="pl-c1">200</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">res</span><span class="pl-kos">.</span><span class="pl-c1">statusCode</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">300</span> ?
        <span class="pl-s1">resolve</span> :
        <span class="pl-s1">reject</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<h1 dir="auto">solution</h1>
<p dir="auto">it's been discussed somewhat in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="45530957" data-permission-text="Title is private" data-url="https://github.com/axios/axios/issues/18" data-hovercard-type="issue" data-hovercard-url="/axios/axios/issues/18/hovercard" href="https://github.com/axios/axios/issues/18">#18</a>, but I think we need to perhaps create a new Error proto, extend from error, and add all the response bits into it.  perhaps provide <code class="notranslate">.toJSON</code> to serialize it down nicely to?</p>
<p dir="auto">It is good practice to reject promises with an error object because they have stack traces.</p>
<p dir="auto"><a href="https://github.com/mzabriskie/axios/blob/d93df704a269d3cbf8f00bcd4b2b2489d5b74f49/lib/adapters/http.js#L73">When rejecting because of a bad status code</a>, I suggest rejecting with an error object, e.g. <code class="notranslate">BadStatusCodeError</code>. You could then attach the response object to the error object so it can be accessed in a rejection handler.</p>