use of ratpack.error.ClientErrorHandler in project ratpack by ratpack.
the class DefaultRequestFixture method getEffectiveRegistry.
private Registry getEffectiveRegistry(final DefaultHandlingResult.ResultsHolder results) {
ClientErrorHandler clientErrorHandler = (context, statusCode) -> {
results.setClientError(statusCode);
context.getResponse().status(statusCode);
results.getLatch().countDown();
};
ServerErrorHandler serverErrorHandler = (context, throwable1) -> {
results.setThrowable(throwable1);
results.getLatch().countDown();
};
final Registry userRegistry = Registry.builder().add(ClientErrorHandler.class, clientErrorHandler).add(ServerErrorHandler.class, serverErrorHandler).build();
return Exceptions.uncheck(() -> {
ServerConfig serverConfig = serverConfigBuilder.build();
DefaultExecController execController = new DefaultExecController(serverConfig.getThreads());
return ServerRegistry.serverRegistry(new TestServer(), Impositions.none(), execController, serverConfig, r -> userRegistry.join(registryBuilder.build()));
});
}
Aggregations