How to chain Observables and create one common place for error handling
<p>I'm wondering how to write my code in more elegant way... I have two requests, the second request have to wait for the first one. If the first one gets failed the whole sentence should failed, I'm wondering how to catch error in one common place?</p>

<pre><code>    enum TestError: ErrorType {
        case Connection
    }

    private func runTest() {
        rx_firstReq()
            .subscribeNext() { _ in
                return self.rx_secondReq()
                    .subscribeNext() { _ in
                        print("whole req sequence finished with success!")
                }.addDisposableTo(self.myDisposeBag)
        }.addDisposableTo(myDisposeBag)
    }

    func rx_firstReq() -&gt; Observable&lt;Bool&gt; {
        return Observable.create() { observable -&gt; Disposable in
            observable.onError(TestError.Connection) // We are assuming that first req gets failed
            observable.onCompleted()

            return NopDisposable.instance
        }
    }

    func rx_secondReq() -&gt; Observable&lt;Bool&gt; {
        return Observable.create() { observable -&gt; Disposable in
            observable.onNext(true)
            observable.onCompleted()

            return NopDisposable.instance
        }
    }
</code></pre>

<p>As you see there is no any place for error handling... I have no idea how to model it, at this moment each next request in my chain gonna create next indentation level... in my opinion it is not good usage of the RxSwift... </p>

<p>..some hint or link with example code with handling error in common place will be great for me.</p>