gpt4 book ai didi

com.netflix.zuul.exception.ZuulException.getStatusCode()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 04:14:49 25 4
gpt4 key购买 nike

本文整理了Java中com.netflix.zuul.exception.ZuulException.getStatusCode()方法的一些代码示例,展示了ZuulException.getStatusCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZuulException.getStatusCode()方法的具体详情如下:
包路径:com.netflix.zuul.exception.ZuulException
类名称:ZuulException
方法名:getStatusCode

ZuulException.getStatusCode介绍

暂无

代码示例

代码示例来源:origin: Netflix/zuul

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  int status = 500;
  final String errorMsg = "ClientResponseWriter caught exception in client connection pipeline: " +
      ChannelUtils.channelInfoForLogging(ctx.channel());
  if (cause instanceof ZuulException) {
    final ZuulException ze = (ZuulException) cause;
    status = ze.getStatusCode();
    LOG.error(errorMsg, cause);
  }
  else if (cause instanceof ReadTimeoutException) {
    LOG.error(errorMsg + ", Read timeout fired");
    status = 504;
  }
  else {
    LOG.error(errorMsg, cause);
  }
  if (isHandlingRequest && !startedSendingResponseToClient && ctx.channel().isActive()) {
    final HttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.valueOf(status));
    ctx.writeAndFlush(httpResponse).addListener(ChannelFutureListener.CLOSE);
    startedSendingResponseToClient = true;
  }
  else {
    ctx.close();
  }
}

代码示例来源:origin: Netflix/zuul

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  int status = 500;
  final String errorMsg = "ClientResponseWriter caught exception in client connection pipeline: " +
      ChannelUtils.channelInfoForLogging(ctx.channel());
  if (cause instanceof ZuulException) {
    final ZuulException ze = (ZuulException) cause;
    status = ze.getStatusCode();
    LOG.error(errorMsg, cause);
  }
  else if (cause instanceof ReadTimeoutException) {
    LOG.error(errorMsg + ", Read timeout fired");
    status = 504;
  }
  else {
    LOG.error(errorMsg, cause);
  }
  if (isHandlingRequest && !startedSendingResponseToClient && ctx.channel().isActive()) {
    final HttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.valueOf(status));
    ctx.writeAndFlush(httpResponse).addListener(ChannelFutureListener.CLOSE);
    startedSendingResponseToClient = true;
  }
  else {
    ctx.close();
  }
}

代码示例来源:origin: Netflix/zuul

private void handleError(final Throwable cause) {
  final ZuulException ze = (cause instanceof  ZuulException) ?
      (ZuulException) cause : requestAttemptFactory.mapNettyToOutboundException(cause, context);
  LOG.debug("Proxy endpoint failed.", cause);
  if (! startedSendingResponseToClient) {
    startedSendingResponseToClient = true;
    zuulResponse = new HttpResponseMessageImpl(context, zuulRequest, ze.getStatusCode());
    zuulResponse.getHeaders().add("Connection", "close");   // TODO - why close the connection? maybe don't always want this to happen ...
    zuulResponse.finishBufferedBodyIfIncomplete();
    invokeNext(zuulResponse);
  } else {
    channelCtx.fireExceptionCaught(ze);
  }
}

代码示例来源:origin: Netflix/zuul

private void handleError(final Throwable cause) {
  final ZuulException ze = (cause instanceof  ZuulException) ?
      (ZuulException) cause : requestAttemptFactory.mapNettyToOutboundException(cause, context);
  LOG.debug("Proxy endpoint failed.", cause);
  if (! startedSendingResponseToClient) {
    startedSendingResponseToClient = true;
    zuulResponse = new HttpResponseMessageImpl(context, zuulRequest, ze.getStatusCode());
    zuulResponse.getHeaders().add("Connection", "close");   // TODO - why close the connection? maybe don't always want this to happen ...
    zuulResponse.finishBufferedBodyIfIncomplete();
    invokeNext(zuulResponse);
  } else {
    channelCtx.fireExceptionCaught(ze);
  }
}

代码示例来源:origin: com.netflix.zuul/zuul-core

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  int status = 500;
  final String errorMsg = "ClientResponseWriter caught exception in client connection pipeline: " +
      ChannelUtils.channelInfoForLogging(ctx.channel());
  if (cause instanceof ZuulException) {
    final ZuulException ze = (ZuulException) cause;
    status = ze.getStatusCode();
    LOG.error(errorMsg, cause);
  }
  else if (cause instanceof ReadTimeoutException) {
    LOG.error(errorMsg + ", Read timeout fired");
    status = 504;
  }
  else {
    LOG.error(errorMsg, cause);
  }
  if (isHandlingRequest && !startedSendingResponseToClient && ctx.channel().isActive()) {
    final HttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.valueOf(status));
    ctx.writeAndFlush(httpResponse).addListener(ChannelFutureListener.CLOSE);
    startedSendingResponseToClient = true;
  }
  else {
    ctx.close();
  }
}

代码示例来源:origin: com.netflix.zuul/zuul-core

private void handleError(final Throwable cause) {
  final ZuulException ze = (cause instanceof  ZuulException) ?
      (ZuulException) cause : requestAttemptFactory.mapNettyToOutboundException(cause, context);
  LOG.debug("Proxy endpoint failed.", cause);
  if (! startedSendingResponseToClient) {
    startedSendingResponseToClient = true;
    zuulResponse = new HttpResponseMessageImpl(context, zuulRequest, ze.getStatusCode());
    zuulResponse.getHeaders().add("Connection", "close");   // TODO - why close the connection? maybe don't always want this to happen ...
    zuulResponse.finishBufferedBodyIfIncomplete();
    invokeNext(zuulResponse);
  } else {
    channelCtx.fireExceptionCaught(ze);
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com