* fix: only caught Exception indicates internal error

caught Error indicates fatal error
* show traceback only when there is an internal error
  or when debug option is set (global!)
* fix: we have --ignore-comar option. so raise exceptions
  when we get comar errors.
This commit is contained in:
Eray Özkural
2005-09-29 12:08:02 +00:00
parent 771d4e512c
commit 1f40387fba
2 changed files with 18 additions and 9 deletions
+13 -6
View File
@@ -23,27 +23,34 @@ def handle_exception(exception, value, tb):
import exceptions
import pisi.ui
import pisi.context as ctx
from pisi.xmlext import XmlError
ui = pisi.cli.CLI()
traceback = False
if exception == exceptions.KeyboardInterrupt:
ui.error(_("\nKeyboardInterrupt: Exiting...\n"))
sys.exit(1)
elif exception == XmlError:
ui.error(str(value))
sys.exit(1)
ui.error(_("""
elif exception == pisi.Exception:
ui.error(_("""
Internal PISI Error:
Please file a bug report! (http://bugs.uludag.org.tr)
"""))
traceback = True
elif exception == pisi.Error:
ui.error(_("Fatal Error:"))
traceback = ctx.options and ctx.options.debug
ui.error("%s" %exception)
ui.error("%s\n" %value)
ui.info(_("Traceback:"))
traceback.print_tb(tb)
if traceback:
ui.info(_("Traceback:"))
traceback.print_tb(tb)
sys.exit(1)
if __name__ == "__main__":
+5 -3
View File
@@ -17,6 +17,9 @@ import sys
ver = sys.version_info
if ver[0] <= 2 and ver[1] < 4:
from sets import Set as set
import gettext
__trans = gettext.translation('pisi', fallback=True)
_ = __trans.ugettext
import pisi
@@ -49,11 +52,10 @@ def init(database = True, options = None, ui = None ):
import comar
ctx.comard = comar.Link()
except ImportError:
print "INSTALL COMARD!"
raise Error(_("COMAR: comard not fully installed"))
print "skipping COMAR connection for now..."
except comar.Error:
print "NEXT TIME RUN COMARD FIRST!"
print "skipping COMAR connection for now..."
raise Error(_("COMAR: comard not running or defunct"))
if ui is None:
if options: