use of com.vaadin.flow.router.NotFoundException in project flow by vaadin.
the class DefaultRouteResolver method resolve.
@Override
public NavigationState resolve(ResolveRequest request) {
RouteRegistry registry = request.getRouter().getRegistry();
PathDetails path = findPathString(registry, request.getLocation().getSegments());
if (path == null) {
return null;
}
NavigationStateBuilder builder = new NavigationStateBuilder();
Class<? extends Component> navigationTarget;
try {
if (!path.segments.isEmpty()) {
navigationTarget = getNavigationTargetWithParameter(registry, path.path, path.segments);
} else {
navigationTarget = getNavigationTarget(registry, path.path);
}
if (HasUrlParameter.class.isAssignableFrom(navigationTarget)) {
List<String> pathParameters = getPathParameters(request.getLocation().getPath(), path.path);
if (!ParameterDeserializer.verifyParameters(navigationTarget, pathParameters)) {
return null;
}
builder.withTarget(navigationTarget, pathParameters);
} else {
builder.withTarget(navigationTarget);
}
builder.withPath(path.path);
} catch (NotFoundException nfe) {
String message = "Exception while navigation to path " + path;
LoggerFactory.getLogger(this.getClass().getName()).warn(message, nfe);
throw nfe;
}
return builder.build();
}
Aggregations