mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
34 lines
720 B
PHP
34 lines
720 B
PHP
<?php
|
|
namespace SilverStripe\Core\Manifest;
|
|
|
|
use PhpParser\Error;
|
|
use PhpParser\ErrorHandler;
|
|
|
|
/**
|
|
|
|
* Error handler which throws, but retains the original path context.
|
|
* For parsing errors, this is essential information to identify the issue.
|
|
*/
|
|
class ClassManifestErrorHandler implements ErrorHandler
|
|
{
|
|
/**
|
|
* @var String
|
|
*/
|
|
protected $pathname;
|
|
|
|
/**
|
|
* @param String $pathname
|
|
*/
|
|
public function __construct($pathname)
|
|
{
|
|
$this->pathname = $pathname;
|
|
}
|
|
|
|
public function handleError(Error $error)
|
|
{
|
|
$newMessage = sprintf('%s in %s', $error->getRawMessage(), $this->pathname);
|
|
$error->setRawMessage($newMessage);
|
|
throw $error;
|
|
}
|
|
}
|