Skip to content

Commit e808394

Browse files
committed
Adding missing javadocs to Exceptions/OnErrorThrowable (#1322)
1 parent 2d7b966 commit e808394

File tree

2 files changed

+51
-14
lines changed

2 files changed

+51
-14
lines changed

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

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,24 @@ public static RuntimeException propagate(Throwable t) {
4949
}
5050

5151
/**
52-
* @warn javadoc missing
52+
* Throws a particular {@code Throwable} only if it belongs to a set of "fatal" error varieties. These
53+
* varieties are as follows:
54+
* <ul>
55+
* <li>{@link OnErrorNotImplementedException}</li>
56+
* <li>{@link OnErrorFailedException}</li>
57+
* <li>{@code StackOverflowError}</li>
58+
* <li>{@code VirtualMachineError}</li>
59+
* <li>{@code ThreadDeath}</li>
60+
* <li>{@code LinkageError}</li>
61+
* </ul>
62+
* This can be useful if you are writing an operator that calls user-supplied code, and you want to
63+
* notify subscribers of errors encountered in that code by calling their {@code onError} methods, but only
64+
* if the errors are not so catastrophic that such a call would be futile, in which case you simply want to
65+
* rethrow the error.
66+
*
67+
* @param t
68+
* the {@code Throwable} to test and perhaps throw
69+
* @see <a href="https://github.com/Netflix/RxJava/issues/748#issuecomment-32471495">RxJava: StackOverflowError is swallowed (Issue #748)</a>
5370
*/
5471
public static void throwIfFatal(Throwable t) {
5572
if (t instanceof OnErrorNotImplementedException) {
@@ -77,7 +94,13 @@ else if (t instanceof StackOverflowError) {
7794
private static final int MAX_DEPTH = 25;
7895

7996
/**
80-
* @warn javadoc missing
97+
* Adds a {@code Throwable} to a causality-chain of Throwables, as an additional cause (if it does not
98+
* already appear in the chain among the causes).
99+
*
100+
* @param e
101+
* the {@code Throwable} at the head of the causality chain
102+
* @param cause
103+
* the {@code Throwable} you want to add as a cause of the chain
81104
*/
82105
public static void addCause(Throwable e, Throwable cause) {
83106
Set<Throwable> seenCauses = new HashSet<Throwable>();
@@ -106,8 +129,12 @@ public static void addCause(Throwable e, Throwable cause) {
106129
}
107130

108131
/**
109-
* @warn javadoc missing
110-
* @return
132+
* Get the {@code Throwable} at the end of the causality-chain for a particular {@code Throwable}
133+
*
134+
* @param e
135+
* the {@code Throwable} whose final cause you are curious about
136+
* @return the last {@code Throwable} in the causality-chain of {@code e} (or a "Stack too deep to get
137+
* final cause" {@code RuntimeException} if the chain is too long to traverse)
111138
*/
112139
public static Throwable getFinalCause(Throwable e) {
113140
int i = 0;

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
package rx.exceptions;
1717

1818
/**
19-
* @warn javadoc class description missing
19+
* Represents a {@code Throwable} that an {@code Observable} might notify its subscribers of, but that then can
20+
* be handled by an operator that is designed to recover from or react appropriately to such an error. You can
21+
* recover more information from an {@code OnErrorThrowable} than is found in a typical {@code Throwable}, such
22+
* as the item the {@code Observable} was trying to emit at the time the error was encountered.
2023
*/
2124
public class OnErrorThrowable extends RuntimeException {
2225

@@ -38,8 +41,9 @@ private OnErrorThrowable(Throwable exception, Object value) {
3841
}
3942

4043
/**
41-
* @warn javadoc missing
42-
* @return
44+
* Get the value associated with this {@code OnErrorThrowable}
45+
*
46+
* @return the value associated with this {@code OnErrorThrowable} (or {@code null} if there is none)
4347
*/
4448
public Object getValue() {
4549
return value;
@@ -72,13 +76,13 @@ public static OnErrorThrowable from(Throwable t) {
7276
}
7377

7478
/**
75-
* Adds the given value as the final cause of the given {@code Throwable} wrapped in
76-
* {@code OnNextValue}/{@code RuntimeException}.
79+
* Adds the given item as the final cause of the given {@code Throwable}, wrapped in {@code OnNextValue}
80+
* (which extends {@code RuntimeException}).
7781
*
7882
* @param e
7983
* the {@link Throwable} to which you want to add a cause
8084
* @param value
81-
* the cause you want to add to {@code e}
85+
* the item you want to add to {@code e} as the cause of the {@code Throwable}
8286
* @return the same {@code Throwable} ({@code e}) that was passed in, with {@code value} added to it as a
8387
* cause
8488
*/
@@ -96,24 +100,30 @@ public static Throwable addValueAsLastCause(Throwable e, Object value) {
96100
}
97101

98102
/**
99-
* @warn javadoc class description missing
103+
* Represents an exception that was encountered while trying to emit an item from an Observable, and
104+
* tries to preserve that item for future use and/or reporting.
100105
*/
101106
public static class OnNextValue extends RuntimeException {
102107

103108
private static final long serialVersionUID = -3454462756050397899L;
104109
private final Object value;
105110

106111
/**
107-
* @warn javadoc missing
112+
* Create an {@code OnNextValue} exception and include in its error message a string representation of
113+
* the item that was intended to be emitted at the time the exception was handled.
114+
*
115+
* @param value
116+
* the item that the Observable was trying to emit at the time of the exception
108117
*/
109118
public OnNextValue(Object value) {
110119
super("OnError while emitting onNext value: " + value);
111120
this.value = value;
112121
}
113122

114123
/**
115-
* @warn javadoc missing
116-
* @return
124+
* Retrieve the item that the Observable was trying to emit at the time this exception occurred.
125+
*
126+
* @return the item that the Observable was trying to emit at the time of the exception
117127
*/
118128
public Object getValue() {
119129
return value;

0 commit comments

Comments
 (0)