Provide a nicer exception when an unknown contract ID is attempted to be

used.

Not part of the build.
This commit is contained in:
mhammond%skippinet.com.au 2002-03-07 12:01:38 +00:00
Родитель a7d47014f5
Коммит 96bb97778b
1 изменённых файлов: 8 добавлений и 1 удалений

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

@ -159,7 +159,14 @@ class _Class:
raise AttributeError, "%s class has no attribute '%s'" % (self.contractid, attr)
def createInstance(self, iid = None):
import xpcom.client
return xpcom.client.Component(self.contractid, _get_good_iid(iid))
try:
return xpcom.client.Component(self.contractid, _get_good_iid(iid))
except xpcom.COMException, details:
import nsError
# Handle "no such component" in a cleaner way for the user.
if details.errno == nsError.NS_ERROR_FACTORY_NOT_REGISTERED:
raise xpcom.COMException(details.errno, "No such component '%s'" % (self.contractid,))
raise # Any other exception reraise.
def getService(self, iid = None):
return serviceManager.getServiceByContractID(self.contractid, _get_good_iid(iid))