title: how to properly throw an error inside switchMap?
body: <p>I need to create a record with the condition that the email has not been used. To this end I try the following service:</p>
  <pre><code>import { Injectable, Injector } from &quot;@angular/core&quot;;
  import { EMPTY, throwError } from &quot;rxjs&quot;;
  import { CustomerModel } from &quot;@app/shared/models&quot;;
  import { ContactsService } from &quot;@app/project/contacts/services/contacts.service&quot;;
  import { switchMap } from &quot;rxjs/operators&quot;;
  
  @Injectable({
    providedIn: &quot;root&quot;,
  })
  export class CustomerService {
    constructor(
      private readonly httpClient: HttpClient,
      private readonly contactsService: ContactsService
    ) {}
  
    create(model: CustomerModel): Observable&lt;CustomerModel&gt; {
      return this.contactsService.verifyContactExists(model.contact.email).pipe(
        switchMap((value) =&gt; {
          if (!value) {
            return this.httpClient.post&lt;CustomerModel&gt;(this.urlEndPoint, model);
          }
  
          throwError(&quot;Email already exists&quot;);
        })
      );
    }
  
    // ...
  }
  </code></pre>
  <p>The create method is handled in the component in a similar way to the following:</p>
  <pre><code>handler(): void {
    const action: Observable&lt;any&gt; = this.customerService.create(contact).pipe(
      map((result) =&gt; {
        this.contactList.push(result);
        return true;
      })
    );
  }
  </code></pre>
  <p>After a brief logic the possible error is handled like this:</p>
  <pre><code>return action.pipe(
    catchError((error: HttpErrorResponse) =&gt; {
      this.toastrService.error(error.error.message, &quot;&quot;, {
        positionClass: &quot;toast-top-right&quot;,
        closeButton: true,
        timeOut: 3000,
      });
      return of(false);
    })
  );
  </code></pre>
  <p>The problem I am experiencing is that when identifying in the create method that the email has already been used and consequently calling <code>throwError('Email already exists');</code>, the behavior that no error is shown occurs and apparently throwError does not cause anything , it simply remains in an operation that never ends.</p>
  <p>I am new to ngrx and am having trouble on how to properly handle these scenarios. I would appreciate your advice</p>
  <p>Greetings and thanks</p>