本文整理汇总了Java中com.netflix.zuul.context.RequestContext.getThrowable方法的典型用法代码示例。如果您正苦于以下问题:Java RequestContext.getThrowable方法的具体用法?Java RequestContext.getThrowable怎么用?Java RequestContext.getThrowable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.zuul.context.RequestContext
的用法示例。
在下文中一共展示了RequestContext.getThrowable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
Throwable throwable = ctx.getThrowable();
if (throwable != null) {
ctx.setResponseStatusCode(500);
}
return null;
}
示例2: run
import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
@Override
public Object run() {
RequestContext context = RequestContext.getCurrentContext();
Throwable throwable = context.getThrowable();
context.set("error.status_code", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
context.set("exception", throwable.getCause());
return null;
}
示例3: run
import com.netflix.zuul.context.RequestContext; //导入方法依赖的package包/类
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
Object spanObject = ctx.get(TracePreZuulFilter.CONTEXT_SPAN_KEY);
if (spanObject instanceof Span) {
Span span = (Span) spanObject;
span.setTag(Tags.HTTP_STATUS.getKey(), ctx.getResponseStatusCode());
if (ctx.getThrowable() != null) {
onError(ctx.getThrowable(), span);
} else {
Object error = ctx.get("error.exception");
if (error instanceof Exception) {
onError((Exception) error, span);
}
}
if (ctx.getRouteHost() != null) {
span.setTag(ROUTE_HOST_TAG, ctx.getRouteHost().toString());
}
span.finish();
}
return null;
}