本文整理了Java中com.netflix.zuul.exception.ZuulException.getStatusCode()
方法的一些代码示例,展示了ZuulException.getStatusCode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZuulException.getStatusCode()
方法的具体详情如下:
包路径:com.netflix.zuul.exception.ZuulException
类名称: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!