Catching Error in Subfunction with Global try/catch
Mostrar comentarios más antiguos
Hi, I have GUI that runs from CSTMainWindow.m. From there a GUI displays which can lead to other GUIs, coded in different files.
I want it to have a bug reporting system. Normally CSTMainWindow is the function run to starting everything, but I changed it so that the function run is CeleST, defined below:
function CeleST
try
% Global try-catch on CeleST
CSTMainWindow()
catch exception
generateReport(exception)
end
generateReport is the bugReporter, just sends an e-mail to me with error stack and a message from the user.
QUESTION: The CSTMainWindow GUI has pushButtons that call other GUI files. However when an error occurs there, it is not caught by the try/catch block. Is this because they are subfunctions, or could it be something I'm not aware of in how the try/catch system works?
Below is an example of one pushButton defintion in CSTMainWindow as well as the subfunction it calls:
uicontrol('parent',mainPanel,'style','pushbutton','string','2. Compute measures...','position',[700 yFilters+hFilters+10 170 60],'callback',@checkResults);
;
function checkResults(hObject,eventdata) %#ok<INUSD>
set(mainFigure,'Visible','off');
CSTCheckResults
set(mainFigure,'Visible','on');
flagConsistentButton = false;
checkSequences
populateFilters
end
And the error that is not caught (q is an undefined fake variable to purposely cause an error):
Undefined function or variable 'q'.
Error in CSTCheckResults (line 109)
filterH = q;
Error in CSTMainWindow/checkResults (line 234)
CSTCheckResults
Error using waitfor
Error while evaluating UIControl Callback
As said earlier, CSTCheckResults is a programmatic GUI file
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Code Execution en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!