Add a return false if category doesn't exist

If DEBUG_MODE is off, exception is not throw. False is returned instead.
This commit is contained in:
jerrywham 2021-12-20 15:06:37 +00:00 committed by GitHub
parent 83914e7601
commit 23019a31c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,9 +15,13 @@ class Category {
$this->vars['permalink'] = DOMAIN_CATEGORIES . $key; $this->vars['permalink'] = DOMAIN_CATEGORIES . $key;
$this->vars['list'] = $categories->db[$key]['list']; $this->vars['list'] = $categories->db[$key]['list'];
} else { } else {
$errorMessage = 'Category not found in database by key ['.$key.']'; $errorMessage = 'Category not found in database by key ['.$key.']';
Log::set(__METHOD__.LOG_SEP.$errorMessage); Log::set(__METHOD__.LOG_SEP.$errorMessage);
throw new Exception($errorMessage); if (DEBUG_MODE === true) {
throw new Exception($errorMessage);
} else {
return false;
}
} }
} }
@ -75,4 +79,4 @@ class Category {
return json_encode($tmp); return json_encode($tmp);
} }
} }