title: How to bubble error correctly from Promise without throw?
body: <p>I have the following <code>TypeScript</code> method which returns a promise:</p>
  
  <pre><code>public loadSavedLogin(): ng.IPromise&lt;MyApp.Models.User&gt; {
     return this._myAppService.getUser(this.savedUserId).then((result: MyApp.Models.User) =&gt; {
         if (result) {
            this.userId = result.UserID;
            this.userName = result.UserName;
          }
          return result;
       }, (error) =&gt; {
             this._isAuthError = true;
             return  error;
       }
    );
  }
  </code></pre>
  
  <p>The problem I have is in the promise's <code>error</code> callback. The upstream calls to this method also rely on a promise so if the error does not bubble up correctly, the upstream promise doesn't function correctly. I found a <em>hackish</em> solution:</p>
  
  <pre><code>(error) =&gt; {
  
        try {
               this._isAuthError = true;
               return error;
             } catch (e) {
                //If any error occurred above make sure to still throw
                throw error;
             } finally {
                  //Allow upstream promises to continue as expected
                  throw error;
             }
   }
  </code></pre>
  
  <p>This works but looks, feels, and is probably all wrong. I feel like I'm missing a proper implementation when handling and bubbling errors in a promise. There has to be a more proper/correct way of handling the error function in <strong>this</strong> promise as I've done, and yet still allow upstream promise's making a call to this method to work properly as well when handling their own error function.</p>
  
  <p>How do I get the error to bubble without the series of hackish <code>throw</code> statements?</p>
  
  <p><strong>Note:</strong> It seems redundant to return the error and throw as well, but the <code>IPromise</code> interface I'm using will not compile if I don't return a value. This is why I return and throw the error.</p>
  
  <p><strong>Note:</strong> I read a ton of the questions on handling errors with promises, but none of them are answering the question as I'm asking in regards to preventing the hackish approach I've taken.</p>