title: Passing errors from Service to Component
body: <p>I'm trying to understand how passing of values or errors works from one component to the other. 
  In my case I want to pass an error from the service to the component, and I have nested methods. </p>
  
  <p>This will be a dummy example. 
  This is the method in the Service which throws an error. </p>
  
  <pre><code>public serviceMethod(value1: Class1): Observable&lt;Interface1&gt;{
      return new Observable(result =&gt; {
        this.method1(class1) // this method throws an error and returns an number 
          .subscribe(decimalValue  =&gt; this.method2(decimalValue) // this method does an error check and returns an Interface1 type
            .subscribe(value2 =&gt; this.method3(value2, result, decimalValue)), error1 =&gt; throwError(error1)
          )
      })
    }
  </code></pre>
  
  <p>Since method1 throws an error, error1 will be thrown too. 
  Now what I want to do, is to pass somehow either a value or the error from the service to the method in another Component. </p>
  
  <p>This is how the method in the other component will be implemented: </p>
  
  <pre><code>    public methodInTheComponent = async () =&gt;{
      this.service.serviceMethod(valueOfClass1).subscribe(result =&gt; concole.log(result), error2 =&gt; console.log(error2));
    }
  </code></pre>
  
  <p>Now, when I run this I just get the output of the error1 thrown, but not that of error2. </p>
  
  <p>The reason for this is that the error is thrown from method1, and it didn't reach the other methods 2 and 3 to return an error result.</p>
  
  <p>One solution which I thought of is using a boolean variable in the service. 
  Like <em>errorThrown = true</em> and then pass this to the component. Then I could do an if check in the subscribtion.<br>
  If the errorThrown is true, error2 should be thrown too. </p>
  
  <p>I'm not sure if this is a good solution! One problem is that I don't know how to send this <em>errorThrown</em> to the Component! </p>
  
  <p>Any suggestion or idea of what could be a possible good solution?</p>