1313
1414use InvalidArgumentException ;
1515use Psr \Http \Message \ResponseInterface ;
16- use RuntimeException ;
16+ use Slim \ Views \ Exception \ PhpTemplateNotFoundException ;
1717use Throwable ;
1818
1919/**
@@ -52,7 +52,7 @@ public function __construct(string $templatePath = '', array $attributes = [], s
5252 * @note $data cannot contain template as a key
5353 *
5454 * @throws InvalidArgumentException
55- * @throws RuntimeException if $templatePath . $template does not exist
55+ * @throws PhpTemplateNotFoundException if $templatePath . $template does not exist
5656 * @throws Throwable
5757 */
5858 public function render (ResponseInterface $ response , string $ template , array $ data = []): ResponseInterface
@@ -82,7 +82,7 @@ public function setLayout(string $layout): void
8282 } else {
8383 $ layoutPath = $ this ->templatePath . $ layout ;
8484 if (!is_file ($ layoutPath )) {
85- throw new RuntimeException ('Layout template " ' . $ layout . '" does not exist ' );
85+ throw new PhpTemplateNotFoundException ('Layout template " ' . $ layout . '" does not exist ' );
8686 }
8787 $ this ->layout = $ layout ;
8888 }
@@ -148,7 +148,7 @@ public function setTemplatePath(string $templatePath): void
148148 * @note $data cannot contain template as a key
149149 *
150150 * @throws InvalidArgumentException
151- * @throws RuntimeException
151+ * @throws PhpTemplateNotFoundException
152152 * @throws Throwable
153153 */
154154 public function fetch (string $ template , array $ data = [], bool $ useLayout = false ): string
@@ -169,7 +169,7 @@ public function fetch(string $template, array $data = [], bool $useLayout = fals
169169 * @note $data cannot contain template as a key
170170 *
171171 * @throws InvalidArgumentException
172- * @throws RuntimeException
172+ * @throws PhpTemplateNotFoundException
173173 * @throws Throwable
174174 */
175175 public function fetchTemplate (string $ template , array $ data = []): string
@@ -179,7 +179,8 @@ public function fetchTemplate(string $template, array $data = []): string
179179 }
180180
181181 if (!is_file ($ this ->templatePath . $ template )) {
182- throw new RuntimeException ('View cannot render " ' . $ template . '" because the template does not exist ' );
182+ throw new PhpTemplateNotFoundException ('View cannot render " ' . $ template
183+ . '" because the template does not exist ' );
183184 }
184185
185186 $ data = array_merge ($ this ->attributes , $ data );
0 commit comments