Merge "Add new dsl exception for better error reporting"
This commit is contained in:
commit
7e07bafb7f
@ -44,8 +44,11 @@ class NoMethodFound(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class NoClassFound(Exception):
|
class NoClassFound(Exception):
|
||||||
def __init__(self, name):
|
def __init__(self, name, packages=[]):
|
||||||
super(NoClassFound, self).__init__('Class "%s" is not found' % name)
|
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):
|
class NoPackageFound(Exception):
|
||||||
|
@ -143,8 +143,8 @@ class MuranoPackage(dsl_types.MuranoPackage):
|
|||||||
result = self._classes.get(name)
|
result = self._classes.get(name)
|
||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if search_requirements:
|
if search_requirements:
|
||||||
|
pkgs_for_search = []
|
||||||
for package_name, version_spec in self._requirements.iteritems():
|
for package_name, version_spec in self._requirements.iteritems():
|
||||||
if package_name == self.name:
|
if package_name == self.name:
|
||||||
continue
|
continue
|
||||||
@ -153,8 +153,11 @@ class MuranoPackage(dsl_types.MuranoPackage):
|
|||||||
try:
|
try:
|
||||||
return referenced_package.find_class(name, False)
|
return referenced_package.find_class(name, False)
|
||||||
except exceptions.NoClassFound:
|
except exceptions.NoClassFound:
|
||||||
|
pkgs_for_search.append(referenced_package)
|
||||||
continue
|
continue
|
||||||
raise exceptions.NoClassFound(name)
|
raise exceptions.NoClassFound(name, packages=pkgs_for_search)
|
||||||
|
|
||||||
|
raise exceptions.NoClassFound(name, packages=[self])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def context(self):
|
def context(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user