APP DESIGNER - How to try and catch TeX syntax?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a uiaxes component and an uieditfield component.
I want the user to be able to change the uiaxes' title using the edit field, in TeX syntax.
My problem is everytime I try to write a wrong TeX syntax string, an error pops out.
I want to be able to catch the error and display an error to the user if the syntax is wrong, instead of matlab going crazy.
This is my code:
try
title(app.MyAxes, app.MyEditField.Value);
catch
SetError(app, 'Invalid TeX syntax');
end
(SetError is a function I made to diplay errors to the user)
this does not work - instead I get this error:
Error using appdesigner.internal.appdesignererrorcallback (line 8)
Error updating Text.
String must have valid interpreter syntax:
MyWrongSyntaxTitle{
Error in appdesigner.internal.service.AppManagementService/axeserrorhandler (line 138)
appdesigner.internal.appdesignererrorcallback(event.Source, event);
Error in appdesigner.internal.service.AppManagementService>@(source,event)obj.axeserrorhandler(event,app) (line 132)
@(source, event)obj.axeserrorhandler(event, app);
Error while evaluating HTMLCanvas ErrorCallback
(MyWrongSyntaxTitle{ is the text I put in the edit field to test the try-catch)
What am I doing wrong? How can I catch this error?
(SetError is never called)
0 comentarios
Respuestas (1)
Roger Parkyn
el 10 de Jun. de 2019
I don't know the answer to your specific quesion but this may help others using appdesigner:
try
some_code; % You can put it around quite large chunks of code so that, at least, it fails more informatively
catch ME % ME is of the class MException (in-built Matlab)
str = sprintf(['Something is wrong with the plotting code. \n' 'Matlab says: \n' ME.message]);
uialert(app.UIFigure, str, 'Plotting Problem');
end
0 comentarios
Ver también
Categorías
Más información sobre Software Development Tools en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!