src/Bundle/Common/File/File.php
protected function customChmod(string $target, $mode = 0666)
    {
        if (false === @chmod($target, $mode & ~umask())) {
            throw new FileException(sprintf('Unable to change mode of the "%s"', $target));
        }
    }
protected function customChmod(string $target, $mode = 0666)
    {
        if (false === @chmod($target, $mode & ~umask())) {
            throw new FileException(sprintf('Unable to change mode of the "%s"', $target));
        }
    }
Chmod function with exception

@param $target
@param $mode
@throws FileException