Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
1002:990e80aa43a9 | 1003:05cc33d8e328 |
---|---|
248 @classmethod | 248 @classmethod |
249 def setMenu(cls, menus): | 249 def setMenu(cls, menus): |
250 main_menu = [] | 250 main_menu = [] |
251 for menu in menus: | 251 for menu in menus: |
252 if not menu: | 252 if not menu: |
253 raise ValueError(_(u"menu item can't be empty")) | 253 msg = _(u"menu item can't be empty") |
254 log.error(msg) | |
255 raise ValueError(msg) | |
254 elif isinstance(menu, list): | 256 elif isinstance(menu, list): |
255 if len(menu) != 2: | 257 if len(menu) != 2: |
256 raise ValueError(_(u"menu item as list must be in the formĀ [page_name, absolue URL]")) | 258 msg = _(u"menu item as list must be in the formĀ [page_name, absolue URL]") |
259 log.error(msg) | |
260 raise ValueError(msg) | |
257 page_name, url = menu | 261 page_name, url = menu |
258 else: | 262 else: |
259 page_name = menu | 263 page_name = menu |
260 url = cls.getPageByName(page_name).url | 264 try: |
265 url = cls.getPageByName(page_name).url | |
266 except KeyError as e: | |
267 log.error(_(u"Can'find a named page ({msg}), please check menu_json in configuration.").format(msg=e)) | |
268 raise e | |
261 main_menu.append((page_name, url)) | 269 main_menu.append((page_name, url)) |
262 cls.main_menu = main_menu | 270 cls.main_menu = main_menu |
263 | 271 |
264 @classmethod | 272 @classmethod |
265 def registerURI(cls, uri_tuple, get_uri_cb, pre_path): | 273 def registerURI(cls, uri_tuple, get_uri_cb, pre_path): |