- Finalizing the documentation before tagging 1.0 release
This commit is contained in:
1 parent
bb29a56077
commit
46535c2734
29 files changed
+933
-211
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<?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
|
||||
{
|
||||
protected Picea $picea;
|
||||
|
||||
public function __construct(object $compiledObject, Picea $picea, string $message, int $code, \Throwable $previous)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
|
||||
$this->picea = $picea;
|
||||
|
||||
$this->defineError($previous, $compiledObject);
|
||||
}
|
||||
|
||||
protected function defineError(\Throwable $previous, object $compiledObject) : void
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user