From ab8105e7f3d6adbea1e4e9de73075a8cdcaa980c Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 12 Aug 2009 22:04:54 +0200 Subject: [PATCH] Make error reporting work for errors in logger. Previously, errors in the logger initialization would cause the exception handling to barf. --- src/main.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.py b/src/main.py index c278d4e..455a34c 100644 --- a/src/main.py +++ b/src/main.py @@ -7,6 +7,7 @@ #tr.go() def run(): + logger = None try: import sys import e32 @@ -19,7 +20,8 @@ def run(): # print os.path.dirname(__file__) # sys.path.append(os.path.dirname(__file__)) import log.logging - from log.logging import logger + from log.logging import logger as _logger + logger = _logger import sys,os logger.log_stderr() sys.stderr.write('stderr logged from default') @@ -70,9 +72,11 @@ def run(): t = appuifw.Text() for trace_line in trace: formatted_trace_line = u'\nIn %s line %s: %s "%s"'%trace_line - logger.log(formatted_trace_line,1) + if logger: + logger.log(formatted_trace_line,1) t.add(formatted_trace_line) - logger.log(error_text,1) + if logger: + logger.log(error_text,1) t.add(error_text) lock = e32.Ao_lock() appuifw.app.menu=[(u'Exit', lock.signal)] @@ -82,7 +86,8 @@ def run(): #appuifw.app.exit_key_handler=gui.exit lock.wait() - logger.close() + if logger: + logger.close() run() -- 2.30.2