diff -r 48ffdc97f54b -r 47446e75ceea index.php --- a/index.php Wed Oct 26 00:37:13 2011 +0200 +++ b/index.php Wed Oct 26 00:56:32 2011 +0200 @@ -6,6 +6,10 @@ const FILE = "var/abook.txt"; +// stop on any error! +set_error_handler(create_function('$a, $b, $c, $d', + 'if (error_reporting()) throw new ErrorException($b, 0, $a, $c, $d);'), -1); + if (isset($_REQUEST['action'])) { require 'addressbook.class.php'; @@ -24,7 +28,15 @@ break; // Suchen… - case 'search': $entries = $abook->search_entries($_REQUEST['pattern']); + case 'search': $entries = null; + $error = null; + try { + $entries = $abook->search_entries($_REQUEST['pattern']); + } + catch (Address_Book_Exception $e) { + $error = $e->getMessage(); + } + if (@$_REQUEST['format'] == 'table') { if (is_numeric($_REQUEST['max'])) { $left = count($entries) - $_REQUEST['max']; @@ -34,13 +46,15 @@ $left = NULL; } echo $twig->render("results.html", - array('entries' => $entries, 'left' => $left)); + array('entries' => $entries, + 'left' => $left, 'error' => $error)); exit; } - echo $twig->render("search.html", array('entries' => $entries)); + echo $twig->render("search.html", + array('entries' => $entries, 'error' => $error)); exit; - break; - } + } + break; } catch (Address_Book_Exception $e) { @@ -50,7 +64,7 @@ } catch (Exception $e) { header("Content-Type: text/plain; charset=utf-8"); - print "Ohoh\n\n" .$e->getMessage(); + print "Ohoh\n\n" . $e; exit; } }