Search in sources :

Example 21 with ZuulException

use of com.netflix.zuul.exception.ZuulException in project zuul by Netflix.

the class BaseZuulFilterRunner method recordFilterError.

protected void recordFilterError(final I inMesg, final ZuulFilter<I, O> filter, final Throwable t) {
    // Add a log statement for this exception.
    final String errorMsg = "Filter Exception: filter=" + filter.filterName() + ", request-info=" + inMesg.getInfoForLogging() + ", msg=" + String.valueOf(t.getMessage());
    if (t instanceof ZuulException && !((ZuulException) t).shouldLogAsError()) {
        logger.warn(errorMsg);
    } else {
        logger.error(errorMsg, t);
    }
    // Store this filter error for possible future use. But we still continue with next filter in the chain.
    final SessionContext zuulCtx = inMesg.getContext();
    zuulCtx.getFilterErrors().add(new FilterError(filter.filterName(), filter.filterType().toString(), t));
    if (zuulCtx.debugRouting()) {
        Debug.addRoutingDebug(zuulCtx, "Running Filter failed " + filter.filterName() + " type:" + filter.filterType() + " order:" + filter.filterOrder() + " " + t.getMessage());
    }
}
Also used : ZuulException(com.netflix.zuul.exception.ZuulException) SessionContext(com.netflix.zuul.context.SessionContext) FilterError(com.netflix.zuul.filters.FilterError)

Example 22 with ZuulException

use of com.netflix.zuul.exception.ZuulException in project zuul by Netflix.

the class ProxyEndpoint method verifyOrigin.

private void verifyOrigin(SessionContext context, HttpRequestMessage request, String restClientName, Origin primaryOrigin) {
    if (primaryOrigin == null) {
        // If no origin found then add specific error-cause metric tag, and throw an exception with 404 status.
        context.put(CommonContextKeys.STATUS_CATGEORY, SUCCESS_LOCAL_NO_ROUTE);
        String causeName = "RESTCLIENT_NOTFOUND";
        originNotFound(context, causeName);
        ZuulException ze = new ZuulException("No origin found for request. name=" + restClientName + ", uri=" + request.reconstructURI(), causeName);
        ze.setStatusCode(404);
        throw ze;
    }
}
Also used : ZuulException(com.netflix.zuul.exception.ZuulException)

Aggregations

ZuulException (com.netflix.zuul.exception.ZuulException)22 RequestContext (com.netflix.zuul.context.RequestContext)5 IOException (java.io.IOException)4 CompleteEvent (com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteEvent)3 CompleteReason (com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteReason)3 SessionContext (com.netflix.zuul.context.SessionContext)3 HttpContent (io.netty.handler.codec.http.HttpContent)3 ClientException (com.netflix.client.ClientException)2 SESSION_COMPLETE (com.netflix.netty.common.HttpLifecycleChannelHandler.CompleteReason.SESSION_COMPLETE)2 OutboundException (com.netflix.zuul.exception.OutboundException)2 ProxyEndpoint (com.netflix.zuul.filters.endpoint.ProxyEndpoint)2 HttpQueryParams (com.netflix.zuul.message.http.HttpQueryParams)2 HttpRequestMessage (com.netflix.zuul.message.http.HttpRequestMessage)2 HttpResponseMessage (com.netflix.zuul.message.http.HttpResponseMessage)2 HttpResponseMessageImpl (com.netflix.zuul.message.http.HttpResponseMessageImpl)2 ChannelUtils (com.netflix.zuul.netty.ChannelUtils)2 PassportState (com.netflix.zuul.passport.PassportState)2 ZuulStatusCategory (com.netflix.zuul.stats.status.ZuulStatusCategory)2 Channel (io.netty.channel.Channel)2 ChannelDuplexHandler (io.netty.channel.ChannelDuplexHandler)2