Exception

Class BlackFox\Exception is a direct descendant of \Exception, in the constructor it receives not only a string, but also an array of strings. This allows you to group exceptions:

$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 \Exception, in this case the method getMessage() glues the array into a string. It is recommended to catch exceptions as \BlackFox\Exception and use the method getArray() to access the array of exception strings.

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.

Own exception

In order to use this exception in your module, you have a choice:

namespace Example;
class Exception extends \BlackFox\Exception {}
Ask question