當前位置: 首頁>>代碼示例>>Java>>正文


Java StreamException類代碼示例

本文整理匯總了Java中io.netty.handler.codec.http2.Http2Exception.StreamException的典型用法代碼示例。如果您正苦於以下問題:Java StreamException類的具體用法?Java StreamException怎麽用?Java StreamException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StreamException類屬於io.netty.handler.codec.http2.Http2Exception包,在下文中一共展示了StreamException類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fromThrowable

import io.netty.handler.codec.http2.Http2Exception.StreamException; //導入依賴的package包/類
/**
 * Converts the {@link Throwable} to a {@link Status}, taking into account exceptions specific to Armeria as
 * well.
 */
public static Status fromThrowable(Throwable t) {
    requireNonNull(t, "t");
    Status s = Status.fromThrowable(t);
    if (s.getCode() != Code.UNKNOWN) {
        return s;
    }
    if (t instanceof StreamException) {
        StreamException streamException = (StreamException) t;
        if (streamException.getMessage() != null && streamException.getMessage().contains("RST_STREAM")) {
            return Status.CANCELLED;
        }
    }
    if (t instanceof ClosedChannelException) {
        // ClosedChannelException is used any time the Netty channel is closed. Proper error
        // processing requires remembering the error that occurred before this one and using it
        // instead.
        return Status.UNKNOWN.withCause(t);
    }
    if (t instanceof IOException) {
        return Status.UNAVAILABLE.withCause(t);
    }
    if (t instanceof Http2Exception) {
        return Status.INTERNAL.withCause(t);
    }
    if (t instanceof ResponseTimeoutException) {
        return Status.DEADLINE_EXCEEDED.withCause(t);
    }
    return s;
}
 
開發者ID:line,項目名稱:armeria,代碼行數:34,代碼來源:GrpcStatus.java

示例2: onStreamError

import io.netty.handler.codec.http2.Http2Exception.StreamException; //導入依賴的package包/類
@Override
protected void onStreamError(ChannelHandlerContext ctx, Throwable cause,
    StreamException http2Ex) {
  logger.log(Level.WARNING, "Stream Error", cause);
  NettyServerStream.TransportState serverStream = serverStream(
      connection().stream(Http2Exception.streamId(http2Ex)));
  if (serverStream != null) {
    serverStream.transportReportStatus(Utils.statusFromThrowable(cause));
  }
  // TODO(ejona): Abort the stream by sending headers to help the client with debugging.
  // Delegate to the base class to send a RST_STREAM.
  super.onStreamError(ctx, cause, http2Ex);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:14,代碼來源:NettyServerHandler.java


注:本文中的io.netty.handler.codec.http2.Http2Exception.StreamException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。