Add new dsl exception for better error reporting
Extend NoClassFound exception for the case when we have parent and child MuranoPL classes in different packages and "parent" package is not present in the requirements section of the "child" package. Change-Id: I41b8033f7e987564ab804d9219eb5063b9e8320b Closes-Bug: #1504334
This commit is contained in:
parent
8ee1335b5e
commit
eaccaf8a83
@ -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