当前位置: 首页>>代码示例>>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;未经允许,请勿转载。