function this = callOutputFcn(this, State)
%

%   Copyright 2016-2022 The MathWorks, Inc.

OutputFcn = this.PrivOptions.OutputFcn;
this.OutputFcnStop = false;
if ~isempty(OutputFcn)
    if ~iscell(OutputFcn)
        OutputFcn = {OutputFcn};
    end
    for i = 1:numel(OutputFcn)
        try
            stop = OutputFcn{i}(this, State);
        catch me
            bayesoptim.warn('OutputFcnError', i);
            bayesoptim.printInfo('ErrorDisplay');
            disp(me.message);
            stop = false;
        end
        if ~(isscalar(stop) && islogical(stop))
            bayesoptim.warn('OutputFcnOutput', i);
        end
        this.OutputFcnStop = this.OutputFcnStop || stop;
    end
end
end
