I am trying to add general custom error handling to App Designer application. One of the use cases is e.g. when an unhandled error would trigger a pop-up window with that error. I see this useful to me for a compiled application without command line.
If there is an error in any callback, AppManagementService instance will catch it in the tryCallback method. This method will also notify listeners using fireCallbackErroredEvent.
I naive way to try to listen that callback could be AppManagementService.instance() since it is referencing to a unique singleton.
service = appdesigner.internal.service.AppManagementService.instance();
addlistener(service, 'CallbackErrored', @app.displayErrorDialog);
However, it is not possible to connect to the notifier since access is restricted only to following to classes:
events (ListenAccess = {?appdesigner.internal.appalert.AppAlertController; ...
?appdesigner.internal.service.WebAppRunner})
I am maybe overengineering the general custom error handling and I am not aware of some functionality in App Designer.
Do you have any suggestions how to approach this problem? Any advice is appreciated.
Edit:
I have created following class inherited from AppAlertController and this class is able to listen CallbackErrored from AppManagementService. It is working in classic Matlab IDE, but not after compilation to standalone app. It seems that supercalss is not being is imported to Matlab runtime.
classdef AppAllertErrorHandler < appdesigner.internal.appalert.AppAlertController
function obj = AppAllertErrorHandler()
service = appdesigner.internal.service.AppManagementService.instance();
obj.CallbackErroredListener = addlistener(service, 'CallbackErrored', @obj.displayErrorDialog);
methods(Access = protected)
function doSendErrorAlertToClient(obj, appException)
methods(Access = private)
function displayErrorDialog(obj, event, source)
Error = source.Exception;
msg = sprintf('Unhandled exception \nIdentifier: %s\nMessage: %s in file %s at line %d ', ...
Error.identifier, Error.message, Error.stack(1).name, Error.stack(1).line);
msgbox(msg, 'Unhandled exception');
Following error is obtained after compilation
Error using AppAllertErrorHandler
The specified superclass 'appdesigner.internal.appalert.AppAlertController' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the same name.
Error in testApp/startupFcn (line 18)
Error in appdesigner.internal.service.AppManagementService/tryCallback (line 371)
Error in appdesigner.internal.service.AppManagementService/runStartupFcn (line 153)
Error in matlab.apps.AppBase/runStartupFcn (line 43)
Error in testApp (line 61)
MATLAB:class:InvalidSuperClass