Skip to content

Commit

Permalink
Merge pull request #315 from benjchristensen/onError-to-throwable
Browse files Browse the repository at this point in the history
Change onError(Exception) to onError(Throwable) - Issue #296
  • Loading branch information
benjchristensen committed Aug 1, 2013
2 parents 7c04f6b + 5316bcc commit 7c5b158
Show file tree
Hide file tree
Showing 61 changed files with 848 additions and 633 deletions.
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;
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

0 comments on commit 7c5b158

Please sign in to comment.