function fault (err_text,data)
% fault: ends current CPRmon operation at an error
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% sample error statement:

%   err_text='';
%   fault(err_text,data);
%   return;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% display error dialog, close figures, & exit program.

fprintf('%s\n',err_text);                      % send error to command window

% send error to error file (if open & FID passed in)
if (nargin==2)
   fprintf(data.config.errfid,'FAULT: %s  %.3f\r\n',err_text,toc);
end;

% send error to error dialog box
error_string=sprintf('"vibration" error:\n\n%s',err_text);
error=errordlg(error_string,'vibration Error');
set(error,'WindowStyle','Modal');

% wait for button push, then exit program
drawnow;
uiwait(error);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
return;
