Error handling with graphical user interface

4 ビュー (過去 30 日間)
William Thielicke
William Thielicke 2024 年 9 月 10 日
コメント済み: William Thielicke 2024 年 9 月 11 日
Hi,
sometimes, a graphical user interface tool that I published crashes. This tool is often used by people that are new to Matlab and / or new to computers. The graphical user interface of my tool runs in a window in front of Matlabs command window. Often, the users do not see the error message in Matlabs command window, but they only notice that the graphical user interface hangs. It then takes an extra step to get the required error message from them to help, and I would like to avoid this.
I am already handling the vast majority of error messages, but sometimes errors still get through.
Therefore my question:
Is it possible to put a simple try / catch / end around my full tool that catches every exception, and then displays the error in a new window in the foreground? I would also like to add hyperlinks to support groups etc. I can do all the latter, but my first attempt to put a try / catch around the GUI figure funtion did not work (I still get the error displayed in Matlabs command window). It is about this main file, all functins are directly or indirectly called from this graphical user interface:

採用された回答

Walter Roberson
Walter Roberson 2024 年 9 月 11 日
When you create a GUI, any try/catch you have only applies to code that is run directly from the try/catch block. The try/catch will not apply to code that is activated by clicking on user interface elements (not unless there is try/catch within that code.) Code that is activated by clicking on user interface elements is effectively run as-if the code were started from the "base" interface as-if it were top-level code.
  1 件のコメント
William Thielicke
William Thielicke 2024 年 9 月 11 日
Any other idea how to make users aware of the command window and / or potential error messages...? Maybe an extra function that runs in the background with a timer and checks if the GUI still responds, and when it does not, it brings the command window to the foreground...?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by