lithium\core\ErrorHandler::handle()

public static method

Receives the handled errors and exceptions that have been caught, and processes them in a normalized manner.

Parameters

  • object|array $info
  • array $scope

Returns

boolean

True if successfully handled, false otherwise.

Source

	public static function handle($info, $scope = []) {
		$checks = static::$_checks;
		$rules = $scope ?: static::$_config;
		$handler = static::$_exceptionHandler;
		$info = is_object($info) ? $handler($info, true) : $info;

		$defaults = [
			'type' => null, 'code' => 0, 'message' => null, 'file' => null, 'line' => 0,
			'trace' => [], 'context' => null, 'exception' => null
		];
		$info = (array) $info + $defaults;

		$info['stack'] = static::trace($info['trace']);
		$info['origin'] = static::_origin($info['trace']);

		foreach ($rules as $config) {
			foreach (array_keys($config) as $key) {
				if ($key === 'conditions' || $key === 'scope' || $key === 'handler') {
					continue;
				}
				if (!isset($info[$key]) || !isset($checks[$key])) {
					continue 2;
				}
				if (($check = $checks[$key]) && !$check($config, $info)) {
					continue 2;
				}
			}
			if (!isset($config['handler'])) {
				return false;
			}
			if ((isset($config['conditions']) && $call = $config['conditions']) && !$call($info)) {
				return false;
			}
			if ((isset($config['scope'])) && static::handle($info, $config['scope']) !== false) {
				return true;
			}
			$handler = $config['handler'];
			return $handler($info) !== false;
		}
		return false;
	}