Skip to content

Commit 104dd68

Browse files
committed
Add split a try/except into two try/excepts.
In an NVDA alpha, there is a bug in brailling code that causes an exception. But with the single try/except, that caused masked as a navigation failure. Now any error message will be better.
1 parent a0fe7d7 commit 104dd68

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

addon/globalPlugins/MathCAT/MathCAT.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,18 @@ def script_navigate(self, gesture: KeyboardInputGesture):
293293
)
294294
# log.info(f"Navigate speech for {gesture.vkCode}/(s={'shift' in modNames}, c={'control' in modNames}): '{text}'")
295295
speech.speak(ConvertSSMLTextForNVDA(text))
296-
296+
except Exception as e:
297+
log.error(e)
298+
# Translators: this message directs users to look in the log file
299+
speech.speakMessage(_("Error in navigating math: see NVDA error log for details"))
300+
301+
try:
297302
# update the braille to reflect the nav position (might be excess code, but it works)
298303
nav_node = libmathcat.GetNavigationMathMLId()
304+
braille_chars = libmathcat.GetBraille(nav_node[0])
305+
log.info(f'braille display = {config.conf["braille"]["display"]}, braille_chars: {braille_chars}')
299306
region = braille.Region()
300-
region.rawText = libmathcat.GetBraille(nav_node[0])
307+
region.rawText = braille_chars
301308
region.focusToHardLeft = True
302309
region.update()
303310
braille.handler.buffer.regions.append(region)
@@ -307,7 +314,7 @@ def script_navigate(self, gesture: KeyboardInputGesture):
307314
except Exception as e:
308315
log.error(e)
309316
# Translators: this message directs users to look in the log file
310-
speech.speakMessage(_("Error in navigating math: see NVDA error log for details"))
317+
speech.speakMessage(_("Error in brailling math: see NVDA error log for details"))
311318

312319
_startsWithMath = re.compile("\\s*?<math")
313320

@@ -426,7 +433,7 @@ def __init__(self):
426433
try:
427434
# IMPORTANT -- SetRulesDir must be the first call to libmathcat besides GetVersion()
428435
rules_dir = path.join(path.dirname(path.abspath(__file__)), "Rules")
429-
# log.info(f"MathCAT {libmathcat.GetVersion()} installed. Using rules dir: {rules_dir}")
436+
log.info(f"MathCAT {libmathcat.GetVersion()} installed. Using rules dir: {rules_dir}")
430437
libmathcat.SetRulesDir(rules_dir)
431438
libmathcat.SetPreference("TTS", "SSML")
432439
except Exception as e:

0 commit comments

Comments
 (0)