Answer the question
In order to leave comments, you need to log in
What's the best way to deal with an exception?
Let's say there are no categories and the model threw an exception
public function allCategories() {
while(!$rows = parent::findAll()){
throw new \Exception('Нет категорий');
}
return $rows;
}
Answer the question
In order to leave comments, you need to log in
And write everything down for yourself, and tell the user that he is trying to look for something wrong
Issue a beautiful warning that the site is down and under maintenance, pledge.
while(!$rows = parent::findAll()){
throw new \Exception('Нет категорий');
}
return $rows;
if (($rows = parent::findAll()) === false);
throw new \Exception('Нет категорий');
}
return $rows;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question