If someone uses a graphical interface and wants to have global error detection, the solution might look something like this:
function varargout = Program(varargin) try gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @program_OpeningFcn, ... 'gui_OutputFcn', @program_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end catch exception beep h = errordlg('Unexpected error, the program will be restarted.','Syntax error','modal'); uiwait(h) Program end
source share