% CancelException - helpers to build the MException with which to cancel a job
% or task.

% Copyright 2011-2014 The MathWorks, Inc.

classdef ( Hidden, Sealed ) CancelException
    methods ( Static )
        function e = getDefaultForTask( user )
            host = iGetHostName();
            e = MException(message('parallel:task:UserCancellation', user, host));
        end
        function e = getWithUserMessageForTask( user, userMessage )
            host = iGetHostName();
            e = MException(message('parallel:task:UserCancellationWithMessage', user, host, userMessage));
        end
        function e = getDefaultForJob( user )
            host = iGetHostName();
            e = MException(message('parallel:job:UserCancellation', user, host));
        end
        function e = getWithUserMessageForJob( user, userMessage )
            host = iGetHostName();
            e = MException(message('parallel:job:UserCancellationWithMessage', user, host, userMessage));
        end
    end
end

function [hostStr] = iGetHostName()
    hostStr= parallel.internal.general.HostNameUtils.getLocalCanonicalHostName();
end
