function out = fixlasterr()
%FIXLASTERR Modify the last error to hide any audioplayer object references.
%
%    FIXLASTERR retrieves the last error message, replaces references
%    to the Java or UDD audioplayer object with more generic 'audioplayer object',
%    and returns the new error as a cell array suitable to be passed into ERROR.
%
%    See Also: ERROR

%    JCS
%    Copyright 2003-2004 The MathWorks, Inc. 
%    $Revision: 1.1.6.2 $  $Date: 2004/07/30 02:17:27 $

[lerr lid] = lasterr;

% look for the java object references in the text and replace the text with
% more generic version
lerr = strrep(lerr, 'in the ''com.mathworks.toolbox.audio.JavaAudioPlayer'' class', 'in the ''audioplayer'' class');
lerr = strrep(lerr, 'com.mathworks.toolbox.audio.JavaAudioPlayer', 'audioplayer objects');
lerr = strrep(lerr, 'audioplayers.winaudioplayer', 'audioplayer objects');
lerr = strrep(lerr, 'winaudioplayer', 'audioplayer');

% check for prepending trace lines.
while strncmp(lerr,'Error using ==>',15) == 1
    [firstline rem] = strtok(lerr,[10 13]);
    lerr = rem(2:length(rem));
end

lasterr(lerr,lid);

if (length(lid)>0)
    out = {lid lerr};
else
    out = {lerr};
end
