From 075d8e7b5cd2606af5bbeaebd517a787a656e8ed Mon Sep 17 00:00:00 2001 From: Phil Burton Date: Wed, 9 Dec 2015 14:47:48 +0000 Subject: Only add red errors when they are config/code errors --- search.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'search.php') diff --git a/search.php b/search.php index cfc1a16..bf2c44a 100644 --- a/search.php +++ b/search.php @@ -22,20 +22,20 @@ function getConfig() throw new Exception('File config.ini does not exist'); } if (!$config = parse_ini_file("config.ini")) { - throw new Exception('Could not parse ini file'); + throw new Exception('Could not parse ini file', 1); } if (!isset($config["url"])) { - throw new Exception('`url` not found in ini file'); + throw new Exception('`url` not found in ini file', 1); } if (!isset($config["command"])) { - throw new Exception('`command` not found in ini file'); + throw new Exception('`command` not found in ini file', 1); } // Set default page size if it's not in the config if (!isset($config["pagesize"])) { $config["pagesize"] = 3; } elseif (!is_int((int)$config["pagesize"]) || $config["pagesize"] < 1) { - throw new Exception('Page size ' . $config["pagesize"] . ' not valid in config'); + throw new Exception('Page size ' . $config["pagesize"] . ' not valid in config', 1); } // hash the password if (isset($config['password'])) { @@ -67,7 +67,8 @@ function getJsonFromUrl($config) "Could not retrive JSON from http server `" . $config["url"] . "?format=json` using password=" - . (isset($config["hash"]) ? "true" : "false") + . (isset($config["hash"]) ? "true" : "false"), + 1 ); } return $output; @@ -275,5 +276,5 @@ try { output($out); } catch (Exception $e) { - output($e->getMessage(), " - ", true); + output($e->getMessage(), " - ", ($e->getCode() == 1)); } -- cgit v1.2.3