Code covered by the BSD License  

Highlights from
Error API for Application Development

image thumbnail

Error API for Application Development

by

 

04 Apr 2006 (Updated )

An API to assist with error reporting in MATLAB applications

xDemo
function xDemo
%XDEMO Demonstrates use of the xError API
%
% xDemo

% Copyright 2006-2010 The MathWorks, Inc.

figure('Name','xError Demo','Position',[300 300 320 190]);
uicontrol('string','Use xError','Position',[10 130 300 30],'callback',@(src,evt) i_xerror);
uicontrol('string','Use error','Position',[10 90 300 30],'callback',@(src,evt) i_error);
uicontrol('string','Do Something Bad','Position',[10 50 300 30],'callback',@(src,evt) i_break);
uicontrol('string','Show Log File','Position',[10 10 300 30],'callback',@(src,evt) xLog);
xLog('Demo started');

end

%%%%%%%%%%%%%%%%%
function i_xerror

try
    xError('Demo:UsingXError','Error thrown using function xError');
catch
    i_display;
end

end

%%%%%%%%%%%%%%%%%
function i_error

try
    error('Demo:UsingError','Error thrown using built-in function "error"');
catch
    i_display;
end

end

%%%%%%%%%%%%%%%%%
function i_break

try
    bar('bar doesn''t accept strings');
catch
    i_display;
end

end

%%%%%%%%%%%%%%%%%
function i_display

errordlg(xLastErr,'Demo Application','modal');

end


Contact us