Skip to content

Instantly share code, notes, and snippets.

@aanandshekharroy
Created February 12, 2018 17:02
Show Gist options
  • Select an option

  • Save aanandshekharroy/e12bbc4fa315a48d61dfa9049c411b7b to your computer and use it in GitHub Desktop.

Select an option

Save aanandshekharroy/e12bbc4fa315a48d61dfa9049c411b7b to your computer and use it in GitHub Desktop.

Revisions

  1. aanandshekharroy created this gist Feb 12, 2018.
    18 changes: 18 additions & 0 deletions doOnError.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    Observable.fromArray(1,2,3)
    .doOnNext {
    if(it==2){
    throw (RuntimeException("Exception on 2"))
    }
    }
    .doOnError {
    println("Doing on error")
    }
    .subscribeBy(
    onNext = {
    println(it)
    },onError = {
    println(it.message)
    },onComplete = {
    println("Complete")
    }
    )