mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 03:16:34 +00:00
fixed message inconsistency
This commit is contained in:
@@ -155,6 +155,12 @@ class Twig_Error extends Exception
|
||||
throw new BadMethodCallException(sprintf('Method "Twig_Error::%s()" does not exist.', $method));
|
||||
}
|
||||
|
||||
public function appendMessage($rawMessage)
|
||||
{
|
||||
$this->rawMessage .= $rawMessage;
|
||||
$this->updateRepr();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
||||
@@ -29,8 +29,7 @@ class Twig_Error_Syntax extends Twig_Error
|
||||
return;
|
||||
}
|
||||
|
||||
$this->rawMessage .= sprintf(' Did you mean "%s"?', implode('", "', $alternatives));
|
||||
$this->updateRepr();
|
||||
$this->appendMessage(sprintf(' Did you mean "%s"?', implode('", "', $alternatives)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-7
@@ -166,17 +166,16 @@ class Twig_Parser implements Twig_ParserInterface
|
||||
$subparser = $this->handlers->getTokenParser($token->getValue());
|
||||
if (null === $subparser) {
|
||||
if (null !== $test) {
|
||||
$error = sprintf('Unexpected tag name "%s"', $token->getValue());
|
||||
$e = new Twig_Error_Syntax(sprintf('Unexpected "%s" tag', $token->getValue()), $token->getLine(), $this->getFilename());
|
||||
|
||||
if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) {
|
||||
$error .= sprintf(' (expecting closing tag for the "%s" tag defined near line %s)', $test[0]->getTag(), $lineno);
|
||||
$e->appendMessage(sprintf(' (expecting closing tag for the "%s" tag defined near line %s).', $test[0]->getTag(), $lineno));
|
||||
}
|
||||
|
||||
throw new Twig_Error_Syntax($error, $token->getLine(), $this->getFilename());
|
||||
} else {
|
||||
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" tag.', $token->getValue()), $token->getLine(), $this->getFilename());
|
||||
$e->addMessageSuggestions($token->getValue(), array_keys($this->env->getTags()));
|
||||
}
|
||||
|
||||
$e = new Twig_Error_Syntax(sprintf('Unknown "%s" tag.', $token->getValue()), $token->getLine(), $this->getFilename());
|
||||
$e->addMessageSuggestions($token->getValue(), array_keys($this->env->getTags()));
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,4 +17,4 @@ Exception for an unclosed tag
|
||||
|
||||
{% endblock %}
|
||||
--EXCEPTION--
|
||||
Twig_Error_Syntax: Unexpected tag name "endblock" (expecting closing tag for the "if" tag defined near line 4) in "index.twig" at line 16
|
||||
Twig_Error_Syntax: Unexpected "endblock" tag (expecting closing tag for the "if" tag defined near line 4) in "index.twig" at line 16.
|
||||
|
||||
Reference in New Issue
Block a user