public static function createDirectories(string $path, int $mode = 0777) : void
    {
        $exception = null;

        try {
            $success = ErrorCatcher::run(static function() use ($path, $mode) {
                return mkdir($path, $mode, true);
            });

            if ($success === true) {
                return;
            }
        } catch (\ErrorException $e) {
            $exception = $e;
        }

        if (self::isDirectory($path)) {
            return;
        }

        throw new IoException('Error creating directories ' . $path, 0, $exception);
    }