use of com.netflix.zuul.exception.ZuulException in project zuul by Netflix.
the class ClientRequestReceiver method write.
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
try (TaskCloseable ignored = PerfMark.traceTask("CRR.write")) {
if (msg instanceof HttpResponse) {
promise.addListener((future) -> {
if (!future.isSuccess()) {
fireWriteError("response headers", future.cause(), ctx);
}
});
super.write(ctx, msg, promise);
} else if (msg instanceof HttpContent) {
promise.addListener((future) -> {
if (!future.isSuccess()) {
fireWriteError("response content", future.cause(), ctx);
}
});
super.write(ctx, msg, promise);
} else {
// should never happen
ReferenceCountUtil.release(msg);
throw new ZuulException("Attempt to write invalid content type to client: " + msg.getClass().getSimpleName(), true);
}
}
}
use of com.netflix.zuul.exception.ZuulException in project zuul by Netflix.
the class OriginResponseReceiver method fireWriteError.
private void fireWriteError(String requestPart, Throwable cause, ChannelHandlerContext ctx) throws Exception {
String errMesg = "Error while proxying " + requestPart + " to origin ";
if (edgeProxy != null) {
final ProxyEndpoint ep = edgeProxy;
edgeProxy = null;
errMesg += ep.getOrigin().getName();
ep.errorFromOrigin(cause);
}
ctx.fireExceptionCaught(new ZuulException(cause, errMesg, true));
}
use of com.netflix.zuul.exception.ZuulException in project zuul by Netflix.
the class Gzipper method write.
public void write(final HttpContent chunk) {
try {
write(chunk.content());
gzos.flush();
} catch (IOException ioEx) {
throw new ZuulException(ioEx, "Error Gzipping response content chunk", true);
} finally {
chunk.release();
}
}
use of com.netflix.zuul.exception.ZuulException in project zuul by Netflix.
the class Gzipper method finish.
public void finish() throws RuntimeException {
try {
gzos.finish();
gzos.flush();
gzos.close();
} catch (IOException ioEx) {
throw new ZuulException(ioEx, "Error finalizing the GzipOutputStream", true);
}
}
use of com.netflix.zuul.exception.ZuulException in project zuul by Netflix.
the class MissingEndpointHandlingFilter method apply.
@Override
public HttpResponseMessage apply(HttpRequestMessage request) {
final SessionContext zuulCtx = request.getContext();
zuulCtx.setErrorResponseSent(true);
final String errMesg = "Missing Endpoint filter, name = " + name;
zuulCtx.setError(new ZuulException(errMesg, true));
LOG.error(errMesg);
return new HttpResponseMessageImpl(zuulCtx, request, 500);
}
Aggregations