code: 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));
          }
      }
docs: Chmod function with exception
  
  @param $target
  @param $mode
  @throws FileException