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

16 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 3 de Oct. de 2021
dbstop if caught error

Más respuestas (0)

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by