- WIP on picea-asset AND error handling
This commit is contained in:
1 parent
3ccbf6bfab
commit
d5de5e665b
7 files changed
+61
-48
No files matched your search
@@ -10,33 +10,20 @@ use Picea\Picea;
|
||||
*/
|
||||
class RenderHtmlException extends \Exception
|
||||
{
|
||||
protected Picea $picea;
|
||||
|
||||
public function __construct(object $compiledObject, Picea $picea, string $message, int $code, \Throwable $previous)
|
||||
public function __construct(object $template, string $message, int $code, \Throwable $previous)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
$this->picea = $picea;
|
||||
|
||||
$this->defineError($previous, $compiledObject);
|
||||
$this->defineError($previous, $template);
|
||||
}
|
||||
|
||||
protected function defineError(\Throwable $previous, object $compiledObject) : void
|
||||
protected function defineError(\Throwable $previous, object $template) : void
|
||||
{
|
||||
$loadedTemplates = array_flip($this->picea->loadedTemplateFile);
|
||||
/*$loadedTemplates = array_flip($this->picea->loadedTemplateFile);*/
|
||||
|
||||
foreach($previous->getTrace() as $trace) {
|
||||
if ( isset($trace['file'], $loadedTemplates[$trace['file']]) ) {
|
||||
$class = $loadedTemplates[ $trace['file'] ];
|
||||
|
||||
$content = include($trace['file']);
|
||||
|
||||
$this->file = $content['view'];
|
||||
$this->line = $class::getSourceLineFromException($trace['line']);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->file = $template::getParam('view');
|
||||
$this->line = $template::getSourceLineFromException($previous->getLine());
|
||||
}
|
||||
|
||||
protected function getTemplateFile(string $filePath) : ? array
|
||||
|
||||
Reference in new issue
Block a user