Search in sources :

Example 1 with FilterError

use of com.netflix.zuul.filters.FilterError 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)

Aggregations

SessionContext (com.netflix.zuul.context.SessionContext)1 ZuulException (com.netflix.zuul.exception.ZuulException)1 FilterError (com.netflix.zuul.filters.FilterError)1