title: Angular - Catch error in component
body: <p>i'm making an app in Angular (5), and i'm not very practice with Subject.
  I want catch the Observable error in my component, but i can't do.
  This is my code</p>
  
  <p>My model:
  <strong>example-model.ts</strong></p>
  
  <pre><code>export class ExampleModel { 
      public value: string; 
  }
  </code></pre>
  
  <p>My Service:
  <strong>example-model-service</strong></p>
  
  <pre><code>@Injectable()
  export class ExampleModelService implements OnDestroy{
  
    destroy$: Subject&lt;boolean&gt; = new Subject&lt;boolean&gt;();
    private exampleModel$ = new ReplaySubject&lt;ExampleModel&gt;(1);
  
    constructor() { }
  
    exampleModelInit(){
      //Observable.from([{'value': 'Hello World'}])
      Observable.create(sub =&gt; sub.error('Observable Error'))
        .pipe(
          distinctUntilChanged(),
          takeUntil(this.destroy$)
        )
        .subscribe((exampleModel: ExampleModel) =&gt; {
          this.sendExampleModel(exampleModel);
        },
          err =&gt; this._handleError(err));
    }
  
    private _handleError(err: any) {
      return Observable.throw(err);
    }
  
    private sendExampleModel(exampleModel: ExampleModel) {
      this.exampleModel$.next(exampleModel);
    }
  
    public whenExampleModel(): Observable&lt;ExampleModel&gt; {
      this.exampleModelInit();
      return this.exampleModel$.asObservable();
    }
  
    ngOnDestroy() {
      this.destroy$.next(true);
      this.destroy$.unsubscribe();
    }
  }
  </code></pre>
  
  <p>My Component:
  <strong>home-component.ts</strong></p>
  
  <pre><code>export class HomeComponent implements OnInit, OnDestroy {
  
    public exampleModel$: Observable&lt;ExampleModel&gt;;
  
    public unsubscribe$: Subject&lt;boolean&gt; = new Subject&lt;boolean&gt;();
  
    controls: boolean = false;
    indicators: boolean = false;
  
    constructor(private exampleModelService$: ExampleModelService) {
    }
  
    ngOnInit() {
    }
  
    getExampleModel() {
      this.exampleModel$ = this.exampleModelService$.whenExampleModel();
  
    }
  
    ngOnDestroy(): void {
      this.unsubscribe$.next(true);
      this.unsubscribe$.unsubscribe();
    }
  
  }
  </code></pre>
  
  <p>I want catch my error in <code>getExampleModel()</code>, i tried with <code>.catch</code> with no result.</p>
  
  <p>Thanks</p>