title: Detect when HTTP error is trigerred in angular when request takes too long
body: <p>I have a function which is used for exporting files to excel. It detects when file is ready and then downloads it. 
  This is how it looks:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>private exportData() {
          this.isExporting = true;
  
          let streams = this.series.filter(s =&gt; !!s.streamId &amp;&amp; !s.value);
          let downloadToken = new Date().getTime() + '_' + (Math.round(Math.random() * 100000000)).toString();
  
          let url = this.service.url + '/export/';
  
          // Create invisible iframe which will navigate to request url.
          // Content-Type will be application/octet-stream, which will cause
          // the browser to download instead of displaying it.
          let element = document.createElement('iframe');
          element.style.visibility = 'hidden';
          document.body.appendChild(element);
          element.src = url;
  
          // Detecting the beginning of a download is absolutely not straight
          // Tried a couple of things, but all event listeners fire when the iframe is created.
          // Ended up with this approach:
          // https://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download
          let interval = Observable.interval(500);
          let subscription = interval.subscribe((value: number) =&gt; {
              if (Cookie.Get('download_token') == downloadToken) {
                  Cookie.Expire('download_token');
                  this.isExporting = false;
                  this.exportModal.close();
                  subscription.unsubscribe();
              }
          }, (error: any) =&gt; {
              this.service.HandleUiError(error);
              this.isExporting = false;
  
          });
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>However, when file is big it sometimes takes long time to create that in the backend, and I get <code>504 Gateway Time-out</code> error, but it is not caught in </p>
  
  <pre><code>                this.service.HandleUiError(error);
                  this.isExporting = false; });
  
  </code></pre>
  
  <p>does anyone know why this could happen and how to fix it?</p>