Catch a few common exceptions, and report them nicely - save the user

wading through screens of traceback information just to find they
spelt an interface name wrong.
This commit is contained in:
mhammond%skippinet.com.au 2002-03-01 06:26:14 +00:00
Родитель 4a5f68a551
Коммит 7a4280940b
1 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -136,8 +136,22 @@ class PythonComponentLoader:
if os.path.splitext(entry.path)[1]==".py":
try:
self.autoRegisterComponent(when, entry)
# Handle some common user errors
except xpcom.COMException, details:
from xpcom import nsError
# If the interface name does not exist, suppress the traceback
if details.errno==nsError.NS_ERROR_NO_INTERFACE:
print "** Registration of '%s' failed\n %s" % (entry.leafName,details.message,)
else:
print "** Registration of '%s' failed!" % (entry.leafName,)
traceback.print_exc()
except SyntaxError, details:
# Syntax error in source file - no useful traceback here either.
print "** Registration of '%s' failed!" % (entry.leafName,)
traceback.print_exception(SyntaxError, details, None)
except:
print "** Registration of '%s' failed!" % (entry.path,)
# All other exceptions get the full traceback.
print "** Registration of '%s' failed!" % (entry.leafName,)
traceback.print_exc()
def autoRegisterComponent (self, when, componentFile):