Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public final class RxJavaExceptionTesting {
public Observable<String> foo1() {
return Observable.empty();
public Observable<String> foo2() {
return Observable.error(new MyException());
public Observable<String> foo3() {
return Observable.error(new MyException("This is a custom exception."));
class MyException extends Exception {
private String message;
public MyException() {
this.message ="";
public MyException(String message) {
this.message = message;
public boolean equals(final Object obj) {
return obj != null
&& obj instanceof MyException
&& Objects.equals(message, ((MyException) obj).message);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment