use of com.netflix.zuul.exception.ErrorType in project zuul by Netflix.
the class BasicNettyOrigin method recordFinalError.
@Override
public void recordFinalError(HttpRequestMessage requestMsg, Throwable throwable) {
if (throwable == null) {
return;
}
final SessionContext zuulCtx = requestMsg.getContext();
// Choose StatusCategory based on the ErrorType.
final ErrorType et = requestAttemptFactory.mapNettyToOutboundErrorType(throwable);
final StatusCategory nfs = et.getStatusCategory();
zuulCtx.put(CommonContextKeys.STATUS_CATGEORY, nfs);
zuulCtx.put(CommonContextKeys.ORIGIN_STATUS_CATEGORY, nfs);
zuulCtx.setError(throwable);
}
use of com.netflix.zuul.exception.ErrorType in project zuul by Netflix.
the class ProxyEndpoint method processErrorFromOrigin.
private void processErrorFromOrigin(final Throwable ex, final Channel origCh) {
try {
final SessionContext zuulCtx = context;
final ErrorType err = requestAttemptFactory.mapNettyToOutboundErrorType(ex);
// Be cautious about how much we log about errors from origins, as it can have perf implications at high rps.
if (zuulCtx.isInBrownoutMode()) {
// Don't include the stacktrace or the channel info.
LOG.warn(err.getStatusCategory().name() + ", origin = " + origin.getName() + ": " + String.valueOf(ex));
} else {
final String origChInfo = (origCh != null) ? ChannelUtils.channelInfoForLogging(origCh) : "";
if (LOG.isInfoEnabled()) {
// Include the stacktrace.
LOG.warn(err.getStatusCategory().name() + ", origin = " + origin.getName() + ", origin channel info = " + origChInfo, ex);
} else {
LOG.warn(err.getStatusCategory().name() + ", origin = " + origin.getName() + ", " + String.valueOf(ex) + ", origin channel info = " + origChInfo);
}
}
// Update the NIWS stat.
if (currentRequestStat != null) {
currentRequestStat.failAndSetErrorCode(err);
}
// Update RequestAttempt info.
if (currentRequestAttempt != null) {
currentRequestAttempt.complete(-1, currentRequestStat.duration(), ex);
}
postErrorProcessing(ex, zuulCtx, err, chosenServer.get(), attemptNum);
final ClientException niwsEx = new ClientException(ClientException.ErrorType.valueOf(err.getClientErrorType().name()));
if (chosenServer.get() != DiscoveryResult.EMPTY) {
origin.onRequestExceptionWithServer(zuulRequest, chosenServer.get(), attemptNum, niwsEx);
}
if ((isBelowRetryLimit()) && (isRetryable(err))) {
// retry request with different origin
passport.add(ORIGIN_RETRY_START);
origin.adjustRetryPolicyIfNeeded(zuulRequest);
proxyRequestToOrigin();
} else {
// Record the exception in context. An error filter should later run which can translate this into an
// app-specific error response if needed.
zuulCtx.setError(ex);
zuulCtx.setShouldSendErrorResponse(true);
StatusCategoryUtils.storeStatusCategoryIfNotAlreadyFailure(zuulCtx, err.getStatusCategory());
origin.recordFinalError(zuulRequest, ex);
origin.onRequestExecutionFailed(zuulRequest, chosenServer.get(), attemptNum - 1, niwsEx);
// Send error response to client
handleError(ex);
}
} catch (Exception e) {
// Use original origin returned exception
handleError(ex);
}
}
use of com.netflix.zuul.exception.ErrorType in project zuul by Netflix.
the class NettyRequestAttemptFactory method mapNettyToOutboundException.
public OutboundException mapNettyToOutboundException(final Throwable t, final SessionContext context) {
if (t instanceof OutboundException) {
return (OutboundException) t;
}
// Map this throwable to zuul's OutboundException.
final ErrorType errorType = mapNettyToOutboundErrorType(t);
final RequestAttempts attempts = RequestAttempts.getFromSessionContext(context);
if (errorType == OTHER) {
return new OutboundException(errorType, attempts, t);
}
return new OutboundException(errorType, attempts);
}
Aggregations