Borrar filtros
Borrar filtros

Throwing errors using NET listeners implemented in a class

2 visualizaciones (últimos 30 días)
I'm implementing a .NET listener to run Matlab callbacks on a .NET application whenever certain buttons are clicked. This is done in a class, based on the instructions here:
These callbacks are supposed to throw errors as popups if the input is incorrect, and they use the error() function to do this. However, when I run the callbacks using the listeners, anything thrown using the error() function gets downgraded to a warning, and it prints in the Command Window instead of showing as a popup. It looks like this:
Warning: Error occurred while executing the listener callback for event Click defined for class System.Windows.Forms.Button:
Error using GetCanConfigForm/btnCreateSimFunc_Listener (line 75)
Please enter the CAN Rx Msg function name to create.
I can catch these "warnings" using try-catch & rethrow the errors using errordlg(). This does make a popup, but the OK buttons on the errordlg popups do nothing instead of closing the popup as expected. The X in the top right corner does work to close the popup.
How do I either force error() to throw popups in this context, or fix the errordlg() OK button to close the popup?
(Using Matlab R2019a)

Respuesta aceptada

Katherine May
Katherine May el 29 de Abr. de 2022
Editada: Katherine May el 29 de Abr. de 2022
I found a fix for the errordlg OK button - I needed to add waitfor():
f = errordlg(errtxt, 'CAN Rx Msg Error');
waitfor(f);
uiwait(f) also works.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by