MATLAB: How to avoid mdbstatus to trigger dbstop in debug mode

MATLAB

In the internal MATLAB file mdbstatus there is a try/error/catch that gets triggered when using dbstop if all error. This block is located in the localGetFileBreakpoints function.
This an inconvenience because I often uses "dbstop if all error" when debugging. But when doing that, this try/catch in mdbstatus often gets tripped, and triggers the breakpoint, so I have to manually `dbcont` out of it. Makes working with the interactive debugger more difficult and annoying.

Best Answer

I confirm that this behavior is expected and using "dbstop if all error" is only recommended for punctual checks as opposed to a general practice in your workflow. 
Here is a patch to temporarily disable dbstop if an error is caught at that specific location:
To apply the patch:
  1. Quit MATLAB if open
  2. In Windows Explorer, navigate to …\toolbox\matlab\codetools in your installation directory, e.g.: C:\Program Files\MATLAB\R2016b\toolbox\matlab\codetools
  3. In that folder, look for "mdbstatus.m"
  4. Create a backup by renaming "mdbstatus.m" to "mdbstatus.m.OriginalBeforePatch"
  5. Copy the patched "mdbstatus.m" into that directory.
  6. Launch MATLAB and confirm that you no longer stop in "mdbstatus"
Note: this patch will only work for MATLAB R2016b.