From beacea0591a22fde654372c19e84e98fa0441908 Mon Sep 17 00:00:00 2001 From: zsxwing Date: Sun, 10 May 2015 21:06:05 -0700 Subject: [PATCH] Change "error[T]" to "error: Observable[Nothing]" --- .../rx/lang/scala/examples/RxScalaDemo.scala | 6 +++++ src/main/scala/rx/lang/scala/Observable.scala | 27 ++++++++++--------- .../scala/rx/lang/scala/ObservableTest.scala | 2 +- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala b/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala index 3735d89e..45564b1c 100644 --- a/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala +++ b/examples/src/test/scala/rx/lang/scala/examples/RxScalaDemo.scala @@ -1676,4 +1676,10 @@ class RxScalaDemo extends JUnitSuite { event1ProducerSubscription.unsubscribe() event2ProducerSubscription.unsubscribe() } + + @Test def errorExample(): Unit = { + val o1 = Observable.just(1, 2, 3) + val o2 = Observable.error(new RuntimeException("Oops")) + (o1 ++ o2).subscribe(v => println(v), e => e.printStackTrace(), () => println("completed")) + } } diff --git a/src/main/scala/rx/lang/scala/Observable.scala b/src/main/scala/rx/lang/scala/Observable.scala index eee0200d..bcc24da5 100644 --- a/src/main/scala/rx/lang/scala/Observable.scala +++ b/src/main/scala/rx/lang/scala/Observable.scala @@ -4303,6 +4303,11 @@ trait Observable[+T] /** * Provides various ways to construct new Observables. + * + * @define noDefaultScheduler + * ===Scheduler:=== + * This method does not operate by default on a particular [[Scheduler]]. + * */ object Observable { import scala.collection.JavaConverters._ @@ -4402,22 +4407,20 @@ object Observable { def apply[T](f: Subscriber[T] => Unit): Observable[T] = { toScalaObservable(rx.Observable.create(f)) } - + /** - * Returns an Observable that invokes an [[rx.lang.scala.Observer]]'s [[rx.lang.scala.Observer.onError onError]] - * method when the Observer subscribes to it. + * Returns an [[Observable]] that invokes an [[Observer.onError]] method when the [[Observer]] subscribes to it. * - * + * * - * @param exception - * the particular error to report - * @tparam T - * the type of the items (ostensibly) emitted by the Observable - * @return an Observable that invokes the [[rx.lang.scala.Observer]]'s [[rx.lang.scala.Observer.onError onError]] - * method when the Observer subscribes to it + * $noDefaultScheduler + * + * @param exception the particular `Throwable` to pass to [[Observer.onError]] + * @return an [[Observable]] that invokes the [[Observer.onError]] method when the [[Observer]] subscribes to it + * @see ReactiveX operators documentation: Throw */ - def error[T](exception: Throwable): Observable[T] = { - toScalaObservable[T](rx.Observable.error(exception)) + def error(exception: Throwable): Observable[Nothing] = { + toScalaObservable[Nothing](rx.Observable.error(exception)) } /** diff --git a/src/test/scala/rx/lang/scala/ObservableTest.scala b/src/test/scala/rx/lang/scala/ObservableTest.scala index e5460563..d2688205 100644 --- a/src/test/scala/rx/lang/scala/ObservableTest.scala +++ b/src/test/scala/rx/lang/scala/ObservableTest.scala @@ -94,7 +94,7 @@ class ObservableTests extends JUnitSuite { val msg = "msg6251" var receivedMsg = "none" try { - Observable.error[Int](new Exception(msg)).firstOrElse(10).toBlocking.single + Observable.error(new Exception(msg)).firstOrElse(10).toBlocking.single } catch { case e: Exception => receivedMsg = e.getCause().getMessage() }