APP DESIGNER - How to try and catch TeX syntax?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Roger Parkyn
le 10 Juin 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 commentaires
Voir également
Catégories
En savoir plus sur Software Development Tools dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!