title: Angular Apollo Error Handling
body: <p>Hi everyone I am a bit stuck on a problem with apollo-angular and apollo-link-error. I've tried a few different ways and I can't seem to catch any errors client-side in my angular web app. I posted my attempts below. Any suggestions or an extra set of eyes would be much appreciated.</p>
  
  <p>Basically all I am trying to do is when an error occurs to prompt my user about the problem. If anyone has some alternate npm package other than apollo-link-error I am all ears.</p>
  
  <p><strong>Attempt 1:</strong></p>
  
  <pre><code>export class AppModule {
    constructor (apollo: Apollo, httpLink: HttpLink) {
      apollo.create({
        link: httpLink.create({
          uri: 'http://localhost:8080/graphql'
        }),
        cache: new InMemoryCache()
      });
  
      const error = onError(({ networkError }) =&gt; {
        const networkErrorRef:HttpErrorResponse = networkError as HttpErrorResponse;
        if (networkErrorRef &amp;&amp; networkErrorRef.status === 401) {
          console.log('Prompt User', error);
        }
      });
    }
  }
  </code></pre>
  
  <p><strong>Attempt 2:</strong></p>
  
  <pre><code>export class AppModule {
    constructor (apollo: Apollo, httpLink: HttpLink) {
      apollo.create({
        link: httpLink.create({
          uri: 'http://localhost:8080/graphql'
        }),
        cache: new InMemoryCache()
      });
  
      const error = onError(({networkError}) =&gt; {
        if (networkError.status === 401) {
          console.log('Prompt User', error);
        }
      });
    }
  }
  </code></pre>
  
  <p><strong>Attempt 3:</strong></p>
  
  <pre><code>export class AppModule {
  constructor (apollo: Apollo, httpLink: HttpLink) {
  apollo.create({
    link: httpLink.create({
      uri: 'http://localhost:8080/graphql'
    }),
    cache: new InMemoryCache()
  });
  
  const link = onError(({ graphQLErrors, networkError }) =&gt; {
    if (graphQLErrors)
      graphQLErrors.map(({ message, locations, path }) =&gt;
        console.log(
          `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
        ),
      );
      if (networkError) console.log(`[Network error]: ${networkError}`);
    });
   }
  }
  </code></pre>