From 94ea72f26ab27810b5b31a6aae7417990e23fbed Mon Sep 17 00:00:00 2001 From: Maarten Date: Mon, 23 Dec 2019 18:56:55 +0100 Subject: [PATCH] Catch twig errors --- src/Runtime/Http/Views/Factory.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/Runtime/Http/Views/Factory.php b/src/Runtime/Http/Views/Factory.php index 9660d42..7519c31 100644 --- a/src/Runtime/Http/Views/Factory.php +++ b/src/Runtime/Http/Views/Factory.php @@ -4,6 +4,7 @@ namespace Runtime\Http\Views; use ClassNotFoundException; +use Runtime\Exceptions\ExceptionHandler; use Twig\Environment; use Twig\Error\LoaderError; use Twig\Error\RuntimeError; @@ -53,23 +54,12 @@ class Factory implements \Runtime\Contracts\View\Factory { $this->name = $this->name($name); $this->arguments = $arguments; - if(!$this->exists()) { - throw new ClassNotFoundException(); + try { + $this->render(); + } + catch (\Exception $e) { + ExceptionHandler::make($e); } - - $this->render(); - - //TODO: Catch errors - } - - /** - * @return bool - */ - private function exists() - { - $file = getcwd() . "/../resources/views/{$this->name}.html"; - //TODO: Add checker - return true; } /**