Merge remote branch 'vicb/template_logical_name'

* vicb/template_logical_name:
  Display template logical names in exception messages
This commit is contained in:
Fabien Potencier 2011-04-11 18:35:51 +02:00
commit aa26624161
5 changed files with 6 additions and 6 deletions

View File

@ -69,7 +69,7 @@ class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface
} }
} }
throw new \RuntimeException(sprintf('No engine is able to work with the %s template.', json_encode($name))); throw new \RuntimeException(sprintf('No engine is able to work with the template "%s".', $name));
} }
/** /**

View File

@ -60,7 +60,7 @@ class TemplateLocator implements FileLocatorInterface
try { try {
return $this->cache[$key] = $this->locator->locate($template->getPath(), $this->path); return $this->cache[$key] = $this->locator->locate($template->getPath(), $this->path);
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template->getLogicalName(), $this->path), 0, $e); throw new \InvalidArgumentException(sprintf('Unable to find template "%s" in "%s".', $template, $this->path), 0, $e);
} }
} }
} }

View File

@ -94,7 +94,7 @@ class FilesystemLoader implements \Twig_LoaderInterface
} }
if (false === $file || null === $file) { if (false === $file || null === $file) {
throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $tpl->getLogicalName()), -1, null, $previous); throw new \Twig_Error_Loader(sprintf('Unable to find template "%s".', $tpl), -1, null, $previous);
} }
return $this->cache[$key] = $file; return $this->cache[$key] = $file;

View File

@ -106,6 +106,6 @@ class DelegatingEngine implements EngineInterface
} }
} }
throw new \RuntimeException(sprintf('No engine is able to work with the %s template.', json_encode($name))); throw new \RuntimeException(sprintf('No engine is able to work with the template "%s".', $name));
} }
} }

View File

@ -82,7 +82,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
$parameters = array_replace($this->getGlobals(), $parameters); $parameters = array_replace($this->getGlobals(), $parameters);
// render // render
if (false === $content = $this->evaluate($storage, $parameters)) { if (false === $content = $this->evaluate($storage, $parameters)) {
throw new \RuntimeException(sprintf('The template "%s" cannot be rendered.', $this->parser->parse($name)->getLogicalName())); throw new \RuntimeException(sprintf('The template "%s" cannot be rendered.', $this->parser->parse($name)));
} }
// decorator // decorator
@ -496,7 +496,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
$storage = $this->loader->load($template); $storage = $this->loader->load($template);
if (false === $storage) { if (false === $storage) {
throw new \InvalidArgumentException(sprintf('The template "%s" does not exist.', is_string($name) ? $name : json_encode($name))); throw new \InvalidArgumentException(sprintf('The template "%s" does not exist.', $template));
} }
return $this->cache[$key] = $storage; return $this->cache[$key] = $storage;