The error handling operators

While developing applications, errors may occur. We have to handle those errors properly to make sure our applications perform seamlessly on the user's end. Take the following program as an example:

    fun main(args: Array<String>) { 
      Observable.just(1,2,3,4,5) 
        .map { it/(3-it) } 
        .subscribe { 
           println("Received $it") 
        } 
    }

Here is the output:

As expected, the program threw an error and that is a bad thing if that occurs on the user end. So, let's take a look at how we can handle errors in a reactive way. RxKotlin provides us with a few operators for error handling, which we'll take a look at. We will use the previous program and apply various error handling operators to them to understand them better.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.226.120