function variantControlVars = findVariantControlVars(modelName)
%

%   Copyright 2022 The MathWorks, Inc.

    variantControlVars = [];
    try
        variantControlVars = Simulink.VariantManager.findVariantControlVars(modelName);
    catch MEx
        % g2731496
        % The call to Simulink.VariantManager.findVariantControlVars throws
        % following license error when both SLDV as well as variant support-package
        % licenses are not available
        % Hence, it's okay to swallow this error and continue as SLDV workflow
        % is expected to fail down the line with SLDV license error itself
        %
        % TODO: Better solution would be to make sure that
        %       Simulink.VariantManager.findVariantControlVars does not report any
        %       variant support-package license error. Instead it should just skip 
        %       that license check if it's called by SLDV. But as it's bit
        %       complicated to achieve this, the API ends up throwing this error
        %       if SLDV (as well as variant support-package) license is not available
        %       In other words, today, this API assumes that the caller is NOT
        %       SLDV if SLDV license is not available. This is a fair expectation,
        %       but in reality SLDV license check happens bit late in SLDV workflow
        %       which is past the invocation of this API
        if strcmp(MEx.identifier, 'Simulink:VariantManager:NeedVariantManagerSPKG')
            return;
        end
    end
end
