title: Calling global handleError function inside catchError RxJs 6 (Migrating from RxJs 5)
body: <p>Recently I upgraded my Ionic 3 project to Ionic 4, with this upgrade a several other packages were updated as well (Angular 5 --> 8 and RxJs 5.5 --> 6.5). Most of the changes needed in code are going well but there is one change I cant resolve.</p>
  
  <p>In one of my services I have a function which does an API fetch (GET). Any errors in the fetch (<code>http GET</code>) are handled in a global error function. In my old Ionic 3 / RxJs 5~ application this was done as follows:</p>
  
  <pre><code>public fetch(): Observable&lt;T[]&gt; {
      let _path: string = this.path; 
      const url = this.getUrl(_path);
  
      return this.http
          .get(url, this.options)
          .catch(this.handleError);
  }
  </code></pre>
  
  <p>The <code>handleError</code> function is defined in another service:</p>
  
  <pre><code>protected handleError(error: any) {
      const errMsg = (error.message) ? error.message :
        error.status ? `${error.status} - ${error.statusText}` : 'Server error';
  
      this.logger.error('API endpoint: ' + this.path, errMsg);
      this.showErrorToast(); // not async in Ionic 3
  
      return Observable.throw(errMsg);
  }
  </code></pre>
  
  <p>In my Ionic 4 / RxJs 6 application I am trying to recreate this without success. 
  I have read and changed the following: </p>
  
  <ul>
  <li><code>catch</code> is deprecated and should be replaced with <code>catchError</code></li>
  <li><code>Observable.throw</code> is also deprecated  and should be replaced by <code>throwError</code></li>
  </ul>
  
  <p>So my new implementation looks as follows:</p>
  
  <pre><code>public fetch(): Observable&lt;T[]&gt; {
      let _path: string = this.path; 
      const url = this.getUrl(_path);
  
      return this.http
          .get(url, this.options)
          .pipe(
            catchError(() =&gt; { // this line is returning a error
              this.handleError;
            }
          ));  
  }
  
  protected handleError(error: any) {
      const errMsg = (error.message) ? error.message :
        error.status ? `${error.status} - ${error.statusText}` : 'Server error';
  
      this.logger.error('API endpoint: ' + this.path, errMsg);
      this.showErrorToast(); // now async in Ionic 4
  
      return throwError(errMsg); // Changed this 
  }
  </code></pre>
  
  <p>However, the <code>catchError(() =&gt;</code> is returning the following error:</p>
  
  <pre><code>Argument of type '() =&gt; void' is not assignable to parameter of type '(err: any, caught: Observable&lt;Object&gt;) =&gt; ObservableInput&lt;any&gt;'.
    Type 'void' is not assignable to type 'ObservableInput&lt;any&gt;'
  </code></pre>
  
  <p>After trying several other things I am a bit clueless how this could be solved, any ideas or pointers?</p>
  
  <p><strong>UPDATE</strong> </p>
  
  <p>After implementing a few of the proposed solutions I keep getting the same, but different error then the previous one:</p>
  
  <pre><code> Type 'Observable&lt;Object&gt;' is not assignable to type 'Observable&lt;T[]&gt;'.
        The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?
          Type 'Object' is missing the following properties from type 'T[]': length, pop, push, concat, and 26 more
  </code></pre>
  
  <p>So after some investigation I came up with this (Using @theMayer proposed solution):</p>
  
  <p>I Changed:</p>
  
  <pre><code>return this.http
      .get(url, this.options)
      .pipe(
        catchError(e =&gt; {
          this.handleError(e);
          return EMPTY;
        }
      ));
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>return this.http
          .get&lt;T[]&gt;(url, this.options)
          .pipe(
            catchError(e =&gt; {
              this.handleError(e);
              return EMPTY;
            }
          ));
  </code></pre>
  
  <p>Above change removes the error but I am not sure this is the way to go? The fetch function will loop over multiple other services which define the API endpoints. </p>