2022-12-21 04:20:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Picea\Exception;
|
|
|
|
|
|
|
|
use Picea\Picea;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whenever an error occured rendering a view, this is the exception that will show up.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class RenderHtmlException extends \Exception
|
|
|
|
{
|
|
|
|
|
2023-10-12 19:07:16 +00:00
|
|
|
public function __construct(object $template, string $message, int $code, \Throwable $previous)
|
2022-12-21 04:20:11 +00:00
|
|
|
{
|
|
|
|
parent::__construct($message, $code, $previous);
|
|
|
|
|
2023-10-12 19:07:16 +00:00
|
|
|
$this->defineError($previous, $template);
|
2022-12-21 04:20:11 +00:00
|
|
|
}
|
|
|
|
|
2023-10-12 19:07:16 +00:00
|
|
|
protected function defineError(\Throwable $previous, object $template) : void
|
2022-12-21 04:20:11 +00:00
|
|
|
{
|
2023-10-12 19:07:16 +00:00
|
|
|
/*$loadedTemplates = array_flip($this->picea->loadedTemplateFile);*/
|
2022-12-21 04:20:11 +00:00
|
|
|
|
2023-10-12 19:07:16 +00:00
|
|
|
$this->file = $template::getParam('view');
|
|
|
|
$this->line = $template::getSourceLineFromException($previous->getLine());
|
2022-12-21 04:20:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTemplateFile(string $filePath) : ? array
|
|
|
|
{
|
|
|
|
$content = null;
|
|
|
|
|
|
|
|
if ( is_array($content) && isset($content['classname'], $content['namespace'], $content['view'], $content['extends']) ) {
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|