Try catch together with dbstop

4 visualizaciones (últimos 30 días)
Sonima
Sonima el 15 de Ag. de 2019
Comentada: Walter Roberson el 15 de Ag. de 2019
Hi All,
I want to use Try Catch together with dbstop. What I want to do is to email ME.message and then breakpoint on error with "dbstop if all error"
function myFunction()
try
xxxx
xxxxxx
xxxx (error occure here!)
xxxxx
catch ME
EmailMe(ME.message);
dbstop if all error
end
Note that after try (xxxx), there are several functions that I cannot repeat the code after "dbstop if all error".
If I put "dbstop if all error" at the begining, then cannot email "ME.message".
Any solusion to this issue?!

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Ag. de 2019
Instead of using dbstop at that point, use keyboard() which gives you a command prompt in debug mode.

Más respuestas (1)

Sonima
Sonima el 15 de Ag. de 2019
Hi and thanks.
keyboard() would just pause the execution and not a breakpoint on error line!
keyboard() is almost the same as pause().
  1 comentario
Walter Roberson
Walter Roberson el 15 de Ag. de 2019
keyboard gives you a command prompt in a debugging session. dbstop calls keyboard() when it detects an error.
dbstop only applies to later errors, not to any error condition you are already in the catch block of.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by