Improve error message on URI with no corresponding route

Created on 7 September 2022, over 2 years ago
Updated 11 September 2023, over 1 year ago

Problem/Motivation

Uninformative error, similar to https://www.drupal.org/project/drupal/issues/3013802 β†’ but this time for function getRouteParameters().

Steps to reproduce

  1. Set a home page node (for example, node/1) at admin/config/system/site-information
  2. Delete this home page node.
  3. Run a page migration, which will result in the following not-very-useful error:
  4. PHP Fatal error: Uncaught UnexpectedValueException: External URLs do not have internal route parameters. in /app/drupal/web/core/lib/Drupal/Core/Url.php:581

Proposed resolution

Patch function getRouteParameters() of core/lib/Drupal/Core/Url.php similar to https://www.drupal.org/project/drupal/issues/3013802 β†’

  public function getRouteParameters() {
    if ($this->unrouted) {
      throw new \UnexpectedValueException($this->getUri() . ' has no corresponding route.');
    }

This results in the following more informative error: PHP Fatal error: Uncaught UnexpectedValueException: base:node/1 has no corresponding route. in /app/drupal/web/core/lib/Drupal/Core/Url.php:581

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States ronaldmulero

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024