When there's an error in a function triggered by Appdesigner, how to stop execution before app management?

조회 수: 13 (최근 30일)
I'm running into an issue with Appdesigner where when my code throws an error, it will propagate all the way to Matlab's app management functions. I'd like to be able to stop execution so that "dbstop if error" causes the function to stop at the line that threw the error (i.e. the typical behavior) instead of showing me the error in the AppManagementService.m file and then not allowing me to "dbup" to my custom function.
For example, I have a "Run" button in my app, which executes a custom function called "Calibration" when clicked. The Calibration.m function does not interact with appdesigner at all, except for being triggered by it. If Calibration.m throws an error on line 50, for example, I want Matlab to stop execution at that line and stay within the "Calibration" function workspace so that I can investigate what's going on (like it normally does with functions that aren't triggered by Appdesigner). Instead, it always takes me to the AppManagementService.m file, line 409, and the stack (using dbstack) doesn't include the Calibration.m function so that I can get back to the Calibration.m workspace.
The best workaround that I've come up with is using a try-catch block to programmatically put a breakpoint at the line that caused the error and then just run the program again. But this is really not great because of the extra processing time involved vs. just being able to pause the program at the error the first time.
Any ideas would be greatly appreciated! Thank you.

채택된 답변

Sean de Wolski
Sean de Wolski 2021년 10월 3일
dbstop if caught error

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Install Products에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by