- // @todo Views should expect and store a leading /. See:
- // https://www.drupal.org/node/2423913
- $rendered_path = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
+ // Wrap this in a try/catch as trying to generate links to some
+ // routes may throw a NotAcceptableHttpException if they do not
+ // respond to HTML, such as RESTExports.
+ try {
+ // @todo Views should expect and store a leading /. See:
+ // https://www.drupal.org/node/2423913
+ $rendered_path = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
+ }
+ catch (NotAcceptableHttpException $e) {
+ $rendered_path = '/' . $path;
+ }