Skip to content

Commit 4328276

Browse files
Refactor to more descriptive name: OnErrorThrowable.addValueAsLastCause
1 parent 3f218d4 commit 4328276

File tree

9 files changed

+23
-9
lines changed

9 files changed

+23
-9
lines changed

rxjava-core/src/main/java/rx/exceptions/OnErrorThrowable.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ public static OnErrorThrowable from(Throwable t) {
5151
}
5252
}
5353

54-
public static Throwable decorate(Throwable e, Object value) {
54+
/**
55+
* Adds the given value as the final cause of the given Throwable wrapped in OnNextValue RuntimeException..
56+
*
57+
* @param e
58+
* @param value
59+
* @return Throwable e passed in
60+
*/
61+
public static Throwable addValueAsLastCause(Throwable e, Object value) {
5562
Exceptions.addCause(e, new OnNextValue(value));
5663
return e;
5764
}

rxjava-core/src/main/java/rx/operators/OperatorCast.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void onNext(T t) {
5050
try {
5151
o.onNext(castClass.cast(t));
5252
} catch (Throwable e) {
53-
onError(OnErrorThrowable.decorate(e, t));
53+
onError(OnErrorThrowable.addValueAsLastCause(e, t));
5454
}
5555
}
5656
};

rxjava-core/src/main/java/rx/operators/OperatorDoOnEach.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void onNext(T value) {
6060
try {
6161
doOnEachObserver.onNext(value);
6262
} catch (Throwable e) {
63-
onError(OnErrorThrowable.decorate(e, value));
63+
onError(OnErrorThrowable.addValueAsLastCause(e, value));
6464
return;
6565
}
6666
observer.onNext(value);

rxjava-core/src/main/java/rx/operators/OperatorFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void onNext(T t) {
5454
child.onNext(t);
5555
}
5656
} catch (Throwable e) {
57-
child.onError(OnErrorThrowable.decorate(e, t));
57+
child.onError(OnErrorThrowable.addValueAsLastCause(e, t));
5858
}
5959
}
6060

rxjava-core/src/main/java/rx/operators/OperatorGroupBy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public void onNext(T t) {
131131
// we have the correct group so send value to it
132132
gps.onNext(t);
133133
} catch (Throwable e) {
134-
onError(OnErrorThrowable.decorate(e, t));
134+
onError(OnErrorThrowable.addValueAsLastCause(e, t));
135135
}
136136
}
137137

rxjava-core/src/main/java/rx/operators/OperatorMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void onNext(T t) {
5353
try {
5454
o.onNext(transformer.call(t));
5555
} catch (Throwable e) {
56-
onError(OnErrorThrowable.decorate(e, t));
56+
onError(OnErrorThrowable.addValueAsLastCause(e, t));
5757
}
5858
}
5959

rxjava-core/src/main/java/rx/operators/OperatorScan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void onNext(T value) {
9797
try {
9898
this.value = accumulator.call(this.value, value);
9999
} catch (Throwable e) {
100-
observer.onError(OnErrorThrowable.decorate(e, value));
100+
observer.onError(OnErrorThrowable.addValueAsLastCause(e, value));
101101
}
102102
}
103103
observer.onNext(this.value);

rxjava-core/src/main/java/rx/operators/OperatorZip.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void tick() {
194194
// all have something so emit
195195
observer.onNext(zipFunction.call(vs));
196196
} catch (Throwable e) {
197-
observer.onError(OnErrorThrowable.decorate(e, vs));
197+
observer.onError(OnErrorThrowable.addValueAsLastCause(e, vs));
198198
return;
199199
}
200200
// now remove them

rxjava-core/src/test/java/rx/operators/OperatorMapTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,14 @@ public String call(String s) {
165165
}
166166
return s;
167167
}
168-
}));
168+
})).doOnError(new Action1<Throwable>() {
169+
170+
@Override
171+
public void call(Throwable t1) {
172+
t1.printStackTrace();
173+
}
174+
175+
});
169176

170177
m.subscribe(stringObserver);
171178
verify(stringObserver, times(1)).onNext("one");

0 commit comments

Comments
 (0)