diff src/server/pages.py @ 1003:05cc33d8e328

server: better error message on init issue / menu_json trouble + stop reactor in this case.
author Goffi <goffi@goffi.org>
date Fri, 05 Jan 2018 16:30:05 +0100
parents 0848b8b0188d
children b57f86bc1177
line wrap: on
line diff
--- a/src/server/pages.py	Fri Jan 05 16:30:05 2018 +0100
+++ b/src/server/pages.py	Fri Jan 05 16:30:05 2018 +0100
@@ -250,14 +250,22 @@
         main_menu = []
         for menu in menus:
             if not menu:
-                raise ValueError(_(u"menu item can't be empty"))
+                msg = _(u"menu item can't be empty")
+                log.error(msg)
+                raise ValueError(msg)
             elif isinstance(menu, list):
                 if len(menu) != 2:
-                    raise ValueError(_(u"menu item as list must be in the formĀ [page_name, absolue URL]"))
+                    msg = _(u"menu item as list must be in the formĀ [page_name, absolue URL]")
+                    log.error(msg)
+                    raise ValueError(msg)
                 page_name, url = menu
             else:
                 page_name = menu
-                url = cls.getPageByName(page_name).url
+                try:
+                    url = cls.getPageByName(page_name).url
+                except KeyError as e:
+                    log.error(_(u"Can'find a named page ({msg}), please check menu_json in configuration.").format(msg=e))
+                    raise e
             main_menu.append((page_name, url))
         cls.main_menu = main_menu