use of com.hotels.styx.api.plugins.spi.PluginException in project styx by ExpediaGroup.
the class HttpErrorStatusMetricsTest method pluginExceptionsAreNotRecordedAsStyxUnexpectedErrors.
@Test
public void pluginExceptionsAreNotRecordedAsStyxUnexpectedErrors() {
errorListener.proxyErrorOccurred(INTERNAL_SERVER_ERROR, new PluginException("bad"));
assertThat(count(ERROR), is(0));
}
use of com.hotels.styx.api.plugins.spi.PluginException in project styx by ExpediaGroup.
the class HttpPipelineHandler method exceptionToResponse.
private LiveHttpResponse exceptionToResponse(Throwable cause, LiveHttpRequest request, CharSequence originsHeaderName) {
HttpResponseStatus status = status(cause instanceof PluginException ? cause.getCause() : cause);
String message = status.code() >= 500 ? "Site temporarily unavailable." : status.description();
LiveHttpResponse.Transformer builder = responseEnhancer.enhance(response(status).body(new ByteStream(Flux.just(new Buffer(message, UTF_8)))).build().newBuilder(), request).header(CONTENT_LENGTH, message.getBytes(UTF_8).length).header(CONNECTION, "close");
if (originsHeaderName != null && originFromException(cause) != null) {
return builder.header(originsHeaderName, originFromException(cause)).build();
} else {
return builder.build();
}
}
Aggregations