
%

%   Copyright 2016 The MathWorks, Inc.

classdef errMsgHandler
    %Util class for generating custom SLDV diagnostic messages

    properties
    end
    
    methods(Static = true)
        function yesno = isInvalidParamTuningError(Mex)
            yesno = strcmp(Mex.identifier,'Simulink:Parameters:ASTReadOnlyIfCompiledMaskField') || ...
                contains(Mex.identifier,'Simulink:Parameters:ASTTune');
        end
        
        function [msg,id] = getInvalidParamTuningError(Mex)
            % See Simulink/en/Parameters.xml
            id = 'Sldv:Compatibility:InvalidParamTuning';
            switch numel(Mex.arguments)
                case 3
                    usedParam = Mex.arguments{3};
                    location = Mex.arguments{2};                    
                    actualParams =  Mex.arguments{3};  
                    % the will correctly map to the placeholder in the string entry 
                    % for InvalidParamTuning in Simulink/en/Parameters.xml
                otherwise 
                    usedParam = Mex.arguments{2};
                    location = Mex.arguments{3};
                    actualParams =  Mex.arguments{4};
            end
            msg = getString(message(id,usedParam,location,actualParams));
        end
    end
    
end

