From 23019a31c1345bc16ee12c15ba045e2784b2458b Mon Sep 17 00:00:00 2001 From: jerrywham Date: Mon, 20 Dec 2021 15:06:37 +0000 Subject: [PATCH] Add a return false if category doesn't exist If DEBUG_MODE is off, exception is not throw. False is returned instead. --- bl-kernel/category.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bl-kernel/category.class.php b/bl-kernel/category.class.php index f48a5970..1f17fc06 100644 --- a/bl-kernel/category.class.php +++ b/bl-kernel/category.class.php @@ -15,9 +15,13 @@ class Category { $this->vars['permalink'] = DOMAIN_CATEGORIES . $key; $this->vars['list'] = $categories->db[$key]['list']; } else { - $errorMessage = 'Category not found in database by key ['.$key.']'; - Log::set(__METHOD__.LOG_SEP.$errorMessage); - throw new Exception($errorMessage); + $errorMessage = 'Category not found in database by key ['.$key.']'; + Log::set(__METHOD__.LOG_SEP.$errorMessage); + if (DEBUG_MODE === true) { + throw new Exception($errorMessage); + } else { + return false; + } } } @@ -75,4 +79,4 @@ class Category { return json_encode($tmp); } -} \ No newline at end of file +}