title: NestJS : Interceptor both map and catchError
body: <p>I need a NestJS interceptor that archives requests, both in exceptional and happy-path cases. Created as follows: </p>
  
  <pre><code>public intercept(context: ExecutionContext, next: CallHandler): Observable&lt;any&gt; {
  
      if (!this.reflector.get&lt;boolean&gt;(RequestMetaData.IS_PUBLIC_ROUTE, context.getHandler())) {
          return next.handle().pipe(
            map(data =&gt; {
                const host = context.switchToHttp();
                const req = host.getRequest();
                const resp = host.getResponse();
                this.persistRequest(data, req, resp)
                  .then(() =&gt; this.logger.log(`Request logged`))
                  .catch(e =&gt; {
                      this.logger.error(`Error logging request: ${e.message}`);
                  });
                return data;
            }));
      }
      return next.handle();
  }
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>This only logs the happy path. Because I'm not familiar with RxJS I created another to persist errors. Eg: </p>
  
  <pre><code>public intercept(context: ExecutionContext, next: CallHandler): Observable&lt;any&gt; {
      return next
        .handle()
        .pipe(
          catchError(err =&gt; {
              return throwError(err);
          })
        );
  }
  </code></pre>
  
  <p>How can I define a single interceptor that archives both paths? </p>