page: catch exceptions in placeholder scripts
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 9 Jul 2018 23:08:53 +0000 (01:08 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 9 Jul 2018 23:52:57 +0000 (01:52 +0200)
Inline error (similar to missing) instead of global breakage.

page.php

index b160e45290295d56bfb30a0fd1b1116eba4465e0..33a1f4440ed5469e3aee9e7be5c27913606053f2 100644 (file)
--- a/page.php
+++ b/page.php
@@ -42,8 +42,15 @@ function getoutput($blocks = [])
                                                $Args .= '/'.$param;
                                        }
                                }
-                               include "$name.php";
-                               $html = ob_get_clean();
+                               try {
+                                       include "$name.php";
+                                       $html = ob_get_clean();
+                               }
+                               catch (Exception $e) {
+                                       $html = sprintf('<strong class="warn">%s</strong>',
+                                               "fout in <em>$name</em>: {$e->getMessage()}"
+                                       );
+                               }
                        }
                        else {
                                $html = '<strong class="warn"><em>'.$name.'</em> ontbreekt</strong>';