use of org.webpieces.router.impl.loader.HaveRouteException in project webpieces by deanhiller.
the class AbstractRouterService method processException.
private Void processException(ResponseStreamer responseCb, RequestContext requestCtx, Throwable e) {
Object meta = "unknown RouteMeta";
//that decision results in the below mess instead of clean code
if (e instanceof HaveRouteException) {
HaveRouteException exc = (HaveRouteException) e;
meta = exc.getResult().getMeta();
}
ErrorRoutes errorRoutes = getErrorRoutes(requestCtx);
routeLoader.processException(responseCb, requestCtx, e, errorRoutes, meta);
return null;
}
use of org.webpieces.router.impl.loader.HaveRouteException in project webpieces by deanhiller.
the class DevRoutingService method incomingRequestImpl.
@Override
public CompletableFuture<Void> incomingRequestImpl(RequestContext ctx, ResponseStreamer responseCb) {
//In DevRouter, check if we need to reload the text file as it points to a new RouterModules.java implementation file
boolean reloaded = reloadIfTextFileChanged();
if (!reloaded)
reloadIfClassFilesChanged();
MatchResult result = fetchRoute(ctx);
CompletableFuture<Void> future;
try {
RouteMeta meta = result.getMeta();
if (meta.getRoute().getRouteType() == RouteType.STATIC) {
//RESET the encodings to known so we don't try to go the compressed cache which doesn't
//exist in dev server since we want the latest files always
ctx.getRequest().encodings = new ArrayList<>();
} else if (meta.getControllerInstance() == null) {
finder.loadControllerIntoMetaObject(meta, false);
finder.loadFiltersIntoMeta(meta, meta.getFilters(), false);
}
future = routeLoader.invokeRoute(result, ctx, responseCb, new DevErrorRoutes(ctx.getRequest()));
} catch (Throwable e) {
future = new CompletableFuture<Void>();
future.completeExceptionally(e);
}
return future.exceptionally(t -> {
throw new HaveRouteException(result, t);
});
}
use of org.webpieces.router.impl.loader.HaveRouteException in project webpieces by deanhiller.
the class ProdRouterService method incomingRequestImpl.
@Override
public CompletableFuture<Void> incomingRequestImpl(RequestContext ctx, ResponseStreamer responseCb) {
MatchResult result = fetchRoute(ctx);
CompletableFuture<Void> future;
try {
ProdErrorRoutes errorRoutes = new ProdErrorRoutes(ctx.getRequest(), routeLoader);
future = routeLoader.invokeRoute(result, ctx, responseCb, errorRoutes);
} catch (Throwable e) {
future = new CompletableFuture<Void>();
future.completeExceptionally(e);
}
return future.exceptionally(t -> {
throw new HaveRouteException(result, t);
});
}
Aggregations