Merge pull request #288 from thewilkybarkid/exception-previous

Add exception chaining
This commit is contained in:
Justin Hileman
2016-03-19 00:35:21 -07:00
8 changed files with 82 additions and 13 deletions
+9 -4
View File
@@ -17,13 +17,18 @@ class Mustache_Exception_SyntaxException extends LogicException implements Musta
protected $token;
/**
* @param string $msg
* @param array $token
* @param string $msg
* @param array $token
* @param Exception $previous
*/
public function __construct($msg, array $token)
public function __construct($msg, array $token, Exception $previous = null)
{
$this->token = $token;
parent::__construct($msg);
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
parent::__construct($msg, 0, $previous);
} else {
parent::__construct($msg);
}
}
/**
@@ -17,12 +17,18 @@ class Mustache_Exception_UnknownFilterException extends UnexpectedValueException
protected $filterName;
/**
* @param string $filterName
* @param string $filterName
* @param Exception $previous
*/
public function __construct($filterName)
public function __construct($filterName, Exception $previous = null)
{
$this->filterName = $filterName;
parent::__construct(sprintf('Unknown filter: %s', $filterName));
$message = sprintf('Unknown filter: %s', $filterName);
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
parent::__construct($message, 0, $previous);
} else {
parent::__construct($message);
}
}
public function getFilterName()
@@ -17,12 +17,18 @@ class Mustache_Exception_UnknownHelperException extends InvalidArgumentException
protected $helperName;
/**
* @param string $helperName
* @param string $helperName
* @param Exception $previous
*/
public function __construct($helperName)
public function __construct($helperName, Exception $previous = null)
{
$this->helperName = $helperName;
parent::__construct(sprintf('Unknown helper: %s', $helperName));
$message = sprintf('Unknown helper: %s', $helperName);
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
parent::__construct($message, 0, $previous);
} else {
parent::__construct($message);
}
}
public function getHelperName()
@@ -17,12 +17,18 @@ class Mustache_Exception_UnknownTemplateException extends InvalidArgumentExcepti
protected $templateName;
/**
* @param string $templateName
* @param string $templateName
* @param Exception $previous
*/
public function __construct($templateName)
public function __construct($templateName, Exception $previous = null)
{
$this->templateName = $templateName;
parent::__construct(sprintf('Unknown template: %s', $templateName));
$message = sprintf('Unknown template: %s', $templateName);
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
parent::__construct($message, 0, $previous);
} else {
parent::__construct($message);
}
}
public function getTemplateName()