- 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
@@ -50,20 +50,21 @@ if (! class_exists("%NAMESPACE%\%CLASSNAME%", false) ) {
|
||||
|
||||
$__event->eventExecute(\Picea\Event\Builder\ClassTemplateOutputing::class, $variablesList);
|
||||
|
||||
( function($___class__template, $___global_variables, $___variables, $__event, $picea) {
|
||||
extract($___global_variables);
|
||||
extract($___variables, \EXTR_OVERWRITE);
|
||||
?>%CONTENT%<?php
|
||||
} )->call($this->thisProxy ?? new class() {}, $this, $this->variableList, $variablesList, $__event, $this->picea);
|
||||
try {
|
||||
( function($___class__template, $___global_variables, $___variables, $__event, $picea) {
|
||||
extract($___global_variables);
|
||||
extract($___variables, \EXTR_OVERWRITE);
|
||||
?>%CONTENT%<?php
|
||||
} )->call($this->thisProxy ?? new class() {}, $this, $this->variableList, $variablesList, $__event, $this->picea);
|
||||
} catch (\Throwable $error) {
|
||||
throw $this->errorHandler($error);
|
||||
}
|
||||
|
||||
$__event->eventExecute(\Picea\Event\Builder\ClassTemplateOutputDone::class, $variablesList);
|
||||
|
||||
# try{
|
||||
%PARENT_OUTPUT%
|
||||
# }
|
||||
# catch(\Exception $e) {
|
||||
# dump($this->isTemplateError($e));
|
||||
# }
|
||||
try { %PARENT_OUTPUT% } catch (\Throwable $error) {
|
||||
throw $this->errorHandler($error);
|
||||
}
|
||||
|
||||
$this->depth--;
|
||||
|
||||
@@ -150,6 +151,25 @@ if (! class_exists("%NAMESPACE%\%CLASSNAME%", false) ) {
|
||||
|
||||
return substr($error->getFile(), -strlen($class)) === $class;
|
||||
}
|
||||
|
||||
protected function errorHandler(\Throwable $error) : \Throwable
|
||||
{
|
||||
$class = substr(static::class, strrpos(static::class, '\\') + 1) . ".php";
|
||||
|
||||
#dump( __NAMESPACE__, basename($error->getFile()), $class );
|
||||
$basename = basename($error->getFile());
|
||||
|
||||
#dump(is_subclass_of(sprintf("\\%s\\%s", __NAMESPACE__, substr($basename,0 , strrpos($basename, '.'))), static::class, true));
|
||||
|
||||
if (str_ends_with($error->getFile(), $class)) {
|
||||
$error = new \Picea\Exception\RenderHtmlException($this, $error->getMessage(), $error->getCode(), $error);
|
||||
}
|
||||
#elseif (is_subclass_of(sprintf("\\%s\\%s", __NAMESPACE__, substr($basename,0 , strrpos($basename, '.'))), static::class, true)) {
|
||||
# $error = new \Picea\Exception\RenderHtmlException($this, $error->getMessage(), $error->getCode(), $error);
|
||||
#}
|
||||
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user