Specify Status*Exception is to be used in StreamObserver.onError

This commit is contained in:
Eric Anderson 2016-04-27 10:16:03 -07:00
parent cd89dde625
commit b0ed77ad81
2 changed files with 8 additions and 0 deletions

View File

@ -392,6 +392,8 @@ public final class Status {
/** /**
* Extract an error {@link Status} from the causal chain of a {@link Throwable}. * Extract an error {@link Status} from the causal chain of a {@link Throwable}.
*
* @return non-{@code null} status
*/ */
public static Status fromThrowable(Throwable t) { public static Status fromThrowable(Throwable t) {
for (Throwable cause : Throwables.getCausalChain(t)) { for (Throwable cause : Throwables.getCausalChain(t)) {

View File

@ -68,6 +68,12 @@ public interface StreamObserver<V> {
* exception is thrown by an implementation of {@code onError} no further calls to any method are * exception is thrown by an implementation of {@code onError} no further calls to any method are
* allowed. * allowed.
* *
* <p>{@code t} should be a {@link io.grpc.StatusException} or {@link
* io.grpc.StatusRuntimeException}, but other {@code Throwable} types are possible. Callers should
* generally convert from a {@link io.grpc.Status} via {@link io.grpc.Status#asException()} or
* {@link io.grpc.Status#asRuntimeException()}. Implementations should generally convert to a
* {@code Status} via {@link io.grpc.Status#fromThrowable(Throwable)}.
*
* @param t the error occurred on the stream * @param t the error occurred on the stream
*/ */
void onError(Throwable t); void onError(Throwable t);