From 850fe76bcb9b33c567f079e4b83fa527e1a5367b Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Sun, 3 Jul 2011 17:39:35 +0200 Subject: Catch and report errors during the creation of menus --- src/Screen.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index d19a0b4..0165bfe 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1387,11 +1387,16 @@ void BScreen::rereadMenu() { l.checkstack(1); lua::stack_sentry s(l); - // XXX try/catch m_rootmenu->removeAll(); - l.loadfile(FbTk::StringUtil::expandFilename(fb->getMenuFilename()).c_str()); - l.call(0, 1); - MenuCreator::createMenu(*m_rootmenu, l, m_rootmenu->reloadHelper()); + try { + l.loadfile(FbTk::StringUtil::expandFilename(fb->getMenuFilename()).c_str()); + l.call(0, 1); + MenuCreator::createMenu(*m_rootmenu, l, m_rootmenu->reloadHelper()); + } + catch(std::runtime_error &e) { + cerr << _FB_CONSOLETEXT(Menu, RootLoad, "Loading root menu failed: ", + "Actual error message follows this string") << e.what() << endl; + } if (m_rootmenu->numberOfItems() == 0) { _FB_USES_NLS; @@ -1421,12 +1426,16 @@ void BScreen::rereadWindowMenu() { l.checkstack(1); lua::stack_sentry s(l); - - // XXX try/catch m_windowmenu->removeAll(); - l.loadfile(FbTk::StringUtil::expandFilename(windowMenuFilename()).c_str()); - l.call(0, 1); - MenuCreator::createMenu(*m_windowmenu, l, m_windowmenu->reloadHelper()); + try { + l.loadfile(FbTk::StringUtil::expandFilename(windowMenuFilename()).c_str()); + l.call(0, 1); + MenuCreator::createMenu(*m_windowmenu, l, m_windowmenu->reloadHelper()); + } + catch(std::runtime_error &e) { + cerr << _FB_CONSOLETEXT(Menu, RootLoad, "Loading window menu failed: ", + "Actual error message follows this string") << e.what() << endl; + } } void BScreen::addConfigMenu(const FbTk::FbString &label, const FbTk::RefCount &menu) { -- cgit v0.11.2