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 ...

Get Reactive Programming in Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.