APP DESIGNER - How to try and catch TeX syntax?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Roger Parkyn
2019-6-10
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!