Exception
Class
BlackFox\Exception
is a direct descendant of
$errors = []; if (empty($user['LOGIN'])) $errors[] = "Specify login"; if (empty($user['EMAIL'])) $errors[] = "Specify email"; if (empty($user['PASSWORD'])) $errors[] = "Specify password"; if ($errors) throw new \BlackFox\Exception($errors);
Further this exception can be caught and processed as
try { // call with possibility of exception } catch (\BlackFox\Exception $Exception) { $errors = $Exception->getArray(); \BlackFox\Engine::I()->ShowErrors($errors); } catch (\Exception $Exception) { $error = $Exception->getMessage(); \BlackFox\Engine::I()->ShowErrors([$error]); }
Descendant classes
The descendant classes listed below do not have any additional internal functionality. Some of them are processed in a special way by the Engine.
- ExceptionAccessDenied — forces the engine to display the authorization page if the user is not authorized
- ExceptionAuthRequired — forces the engine to display the authorization page
- ExceptionCache
- ExceptionElementNotFound — forces the engine to display a 404 page
- ExceptionNotAllowed
- ExceptionNotImplemented
- ExceptionPageNotFound — forces the engine to display a 404 page
- ExceptionSQL
- ExceptionType
Own exception
In order to use this exception in your module, you have a choice:
-
Specify the full path to the exception each time:
throw new \BlackFox\Exception([...]); -
Indicate use at the beginning of the file:
use \BlackFox\Exception; - Create an empty Exception descendant class by placing it in the module's namespace (recommended):
namespace Example; class Exception extends \BlackFox\Exception {}