Merge "Add new dsl exception for better error reporting"

This commit is contained in:
Jenkins 2015-11-09 14:23:22 +00:00 committed by Gerrit Code Review
commit 7e07bafb7f
2 changed files with 10 additions and 4 deletions

View File

@ -44,8 +44,11 @@ class NoMethodFound(Exception):
class NoClassFound(Exception):
def __init__(self, name):
super(NoClassFound, self).__init__('Class "%s" is not found' % name)
def __init__(self, name, packages=[]):
packages = ', '.join("{0}/{1}".format(p.name, p.version)
for p in packages)
super(NoClassFound, self).__init__(
'Class "{0}" is not found in {1}'.format(name, packages))
class NoPackageFound(Exception):

View File

@ -143,8 +143,8 @@ class MuranoPackage(dsl_types.MuranoPackage):
result = self._classes.get(name)
if result:
return result
if search_requirements:
pkgs_for_search = []
for package_name, version_spec in self._requirements.iteritems():
if package_name == self.name:
continue
@ -153,8 +153,11 @@ class MuranoPackage(dsl_types.MuranoPackage):
try:
return referenced_package.find_class(name, False)
except exceptions.NoClassFound:
pkgs_for_search.append(referenced_package)
continue
raise exceptions.NoClassFound(name)
raise exceptions.NoClassFound(name, packages=pkgs_for_search)
raise exceptions.NoClassFound(name, packages=[self])
@property
def context(self):