function fdatoolerror(hFig)
% FDATOOLERROR  FDATool's modal error dialog box.  It displays a cleaned up
%               version of lasterr.  It also resets the mouse pointer
%               and the status line.
% Input:
%   hFig - Handle to the Filter Design GUI figure.

%   Copyright 1988-2000 The MathWorks, Inc.
%   $Revision: 1.4 $  $Date: 2000/07/18 17:16:37 $ 

% Reset mouse pointer and status line.
setptr(hFig,'arrow');
update_status(hFig,'Ready');

errMsg = cleanErrorMsg(lasterr);
errordlg(errMsg,'FDATool Error','modal');

%-------------------------------------------------------------------
function y = removeErrorTraceback(x)
% REMOVEERRORTRACEBACK Removes the error message's back trace.
%
% Input:
%   x - error message
% Output:
%   y - error message without backtrace

iErr = findstr(x,sprintf('Error using ==>'));
if ~isempty(iErr),
    % Traceback present in message
    iCR = findstr(x,char(10));        % Find carriage-return chars
    iFirstCR = find(iCR > iErr(end)); % Find first CR char beyond the last iErr index:
    iBegin = iCR(iFirstCR(1))+1;      % Starting point of "clipped" warning message
    y = x(iBegin:end);                % Construct clipped warning message
else
    % No traceback present in message
    y = x;
end


%-------------------------------------------------------------------
function y = cleanErrorMsg(x)

y = deblank(removeErrorTraceback(x));

% [EOF] fdatoolerror.m
