in menu.inc:
<?php
function menu_item_route_access(Route $route, $href, &$map) {
$request = Request::create('/'. $href);
$request->attributes->set('system_path', $href);
// Attempt to match this path to provide a fully built request to the
// access checker.
try {
$request->attributes->add(Drupal::service('router.dynamic')->matchRequest($request));
}
catch (NotFoundHttpException $e) {
return FALSE;
}
?>
Results in an uncaught exception if you pass in a bad $href that isn't a real system path. On the RequestMatcherInterface that's documented as the exception that will be thrown.