Skip to content

Commit

Permalink
show the passsed context on route match failures
Browse files Browse the repository at this point in the history
  • Loading branch information
AD7six committed Dec 9, 2014
1 parent bfa5584 commit 6eafd23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Routing/RouteCollection.php
Expand Up @@ -235,7 +235,7 @@ public function match($url, $context) {
if ($out) {
return $out;
}
throw new MissingRouteException(['url' => $name]);
throw new MissingRouteException(['url' => $name, 'context' => $context]);
}

foreach ($this->_getNames($url) as $name) {
Expand All @@ -249,7 +249,7 @@ public function match($url, $context) {
}
}
}
throw new MissingRouteException(['url' => var_export($url, true)]);
throw new MissingRouteException(['url' => var_export($url, true), 'context' => $context]);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions src/Template/Error/missing_route.ctp
Expand Up @@ -21,6 +21,8 @@ $this->layout = 'dev_error';
$this->assign('title', 'Missing Route');
$this->assign('templateName', 'missing_route.ctp');

$attributes = $error->getAttributes();

$this->start('subheading');
?>
<strong>Error: </strong>
Expand All @@ -31,6 +33,13 @@ $this->start('subheading');
<p>None of the currently connected routes match the given URL or parameters.
Add a matching route to <?= 'config' . DS . 'routes.php' ?></p>

<?php if (!empty($attributes['context'])): ?>
<p>The passed context was:</p>
<pre>
<?= Debugger::exportVar($attributes['context']); ?>
</pre>
<?php endif; ?>

<h3>Connected Routes</h3>
<table cellspacing="0" cellpadding="0">
<tr><th>Template</th><th>Defaults</th><th>Options</th></tr>
Expand Down

0 comments on commit 6eafd23

Please sign in to comment.