Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change onError(Exception) to onError(Throwable) - Issue #296 #315

Merged
30 changes: 15 additions & 15 deletions rxjava-core/src/main/java/rx/Notification.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class Notification<T> {

private final Kind kind;
private final Exception exception;
private final Throwable throwable;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit s/exception/throwable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will commit change shortly, also changing hasException to hasThrowable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private final T value;

/**
Expand All @@ -34,7 +34,7 @@ public class Notification<T> {
*/
public Notification(T value) {
this.value = value;
this.exception = null;
this.throwable = null;
this.kind = Kind.OnNext;
}

Expand All @@ -44,8 +44,8 @@ public Notification(T value) {
* @param exception
* The exception passed to the onError notification.
*/
public Notification(Exception exception) {
this.exception = exception;
public Notification(Throwable exception) {
this.throwable = exception;
this.value = null;
this.kind = Kind.OnError;
}
Expand All @@ -54,18 +54,18 @@ public Notification(Exception exception) {
* A constructor used to represent an onCompleted notification.
*/
public Notification() {
this.exception = null;
this.throwable = null;
this.value = null;
this.kind = Kind.OnCompleted;
}

/**
* Retrieves the exception associated with an onError notification.
*
* @return The exception associated with an onError notification.
* @return Throwable associated with an onError notification.
*/
public Exception getException() {
return exception;
public Throwable getThrowable() {
return throwable;
}

/**
Expand All @@ -91,8 +91,8 @@ public boolean hasValue() {
*
* @return a value indicating whether this notification has an exception.
*/
public boolean hasException() {
return isOnError() && exception != null;
public boolean hasThrowable() {
return isOnError() && throwable != null;
}

/**
Expand Down Expand Up @@ -125,8 +125,8 @@ public String toString() {
StringBuilder str = new StringBuilder("[").append(super.toString()).append(" ").append(getKind());
if (hasValue())
str.append(" ").append(getValue());
if (hasException())
str.append(" ").append(getException().getMessage());
if (hasThrowable())
str.append(" ").append(getThrowable().getMessage());
str.append("]");
return str.toString();
}
Expand All @@ -136,8 +136,8 @@ public int hashCode() {
int hash = getKind().hashCode();
if (hasValue())
hash = hash * 31 + getValue().hashCode();
if (hasException())
hash = hash * 31 + getException().hashCode();
if (hasThrowable())
hash = hash * 31 + getThrowable().hashCode();
return hash;
}

Expand All @@ -154,7 +154,7 @@ public boolean equals(Object obj) {
return false;
if (hasValue() && !getValue().equals(notification.getValue()))
return false;
if (hasException() && !getException().equals(notification.getException()))
if (hasThrowable() && !getThrowable().equals(notification.getThrowable()))
return false;
return true;
}
Expand Down
Loading