Improve dsl exception readability

Improve dsl exception readability by double quoting names
of classes, properties, and methods mentioned in the exceptions.

Since property names are often lowercase strings (like 'find' or
'environment'), it can be very hard to distinguish a
property name from general exception information in the
error message (especially for someone new to MuranoPL).
This commit improves this situation, by explicitly highlighting
(quoting) the property in question.

Change-Id: Ic9b099818d558b07a38bada56a53d669f5a9299f
This commit is contained in:
Kirill Zaitsev 2015-06-29 08:45:50 +03:00
parent df478681a8
commit aeb9dca1c8
2 changed files with 19 additions and 18 deletions

View File

@ -40,35 +40,36 @@ class DslInvalidOperationError(Exception):
class NoMethodFound(Exception):
def __init__(self, name):
super(NoMethodFound, self).__init__('Method %s is not found' % name)
super(NoMethodFound, self).__init__('Method "%s" is not found' % name)
class NoClassFound(Exception):
def __init__(self, name):
super(NoClassFound, self).__init__('Class %s is not found' % name)
super(NoClassFound, self).__init__('Class "%s" is not found' % name)
class NoPackageFound(Exception):
def __init__(self, name):
super(NoPackageFound, self).__init__('Package %s is not found' % name)
super(NoPackageFound, self).__init__(
'Package "%s" is not found' % name)
class NoPackageForClassFound(Exception):
def __init__(self, name):
super(NoPackageForClassFound, self).__init__('Package for class %s '
super(NoPackageForClassFound, self).__init__('Package for class "%s" '
'is not found' % name)
class NoObjectFoundError(Exception):
def __init__(self, object_id):
super(NoObjectFoundError, self).__init__(
'Object %s is not found in object store' % object_id)
'Object "%s" is not found in object store' % object_id)
class AmbiguousMethodName(Exception):
def __init__(self, name):
super(AmbiguousMethodName, self).__init__(
'Found more that one method %s' % name)
'Found more that one method "%s"' % name)
class DslContractSyntaxError(Exception):
@ -94,32 +95,32 @@ class PropertyAccessError(Exception):
class AmbiguousPropertyNameError(PropertyAccessError):
def __init__(self, name):
super(AmbiguousPropertyNameError, self).__init__(
'Found more that one property %s' % name)
'Found more that one property "%s"' % name)
class NoWriteAccess(PropertyAccessError):
def __init__(self, name):
super(NoWriteAccess, self).__init__(
'Property %s is immutable to the caller' % name)
'Property "%s" is immutable to the caller' % name)
class NoWriteAccessError(PropertyAccessError):
def __init__(self, name):
super(NoWriteAccessError, self).__init__(
'Property %s is immutable to the caller' % name)
'Property "%s" is immutable to the caller' % name)
class PropertyReadError(PropertyAccessError):
def __init__(self, name, murano_class):
super(PropertyAccessError, self).__init__(
'Property %s in class %s cannot be read' %
'Property "%s" in class "%s" cannot be read' %
(name, murano_class.name))
class PropertyWriteError(PropertyAccessError):
def __init__(self, name, murano_class):
super(PropertyAccessError, self).__init__(
'Property %s in class %s cannot be written' %
'Property "%s" in class "%s" cannot be written' %
(name, murano_class.name))
@ -127,4 +128,4 @@ class UninitializedPropertyAccessError(PropertyAccessError):
def __init__(self, name, murano_class):
super(PropertyAccessError, self).__init__(
'Access to uninitialized property '
'%s in class %s is forbidden' % (name, murano_class.name))
'"%s" in class "%s" is forbidden' % (name, murano_class.name))

View File

@ -41,15 +41,15 @@ class TestPropertyAccess(test_case.DslTestCase):
exceptions.UninitializedPropertyAccessError,
self._runner.testUninitializedPrivatePropertyAccess)
self.assertEqual(
'Access to uninitialized property privateName '
'in class SampleClass3 is forbidden', str(e))
'Access to uninitialized property "privateName" '
'in class "SampleClass3" is forbidden', str(e))
def test_read_of_private_property_of_other_class(self):
e = self.assertRaises(
exceptions.PropertyAccessError,
self._runner.testReadOfPrivatePropertyOfOtherClass)
self.assertEqual(
'Property privateProperty in class DerivedFrom2Classes '
'Property "privateProperty" in class "DerivedFrom2Classes" '
'cannot be read', str(e))
self.assertEqual(['accessing property'], self.traces)
@ -58,7 +58,7 @@ class TestPropertyAccess(test_case.DslTestCase):
exceptions.PropertyAccessError,
self._runner.testWriteOfPrivatePropertyOfOtherClass)
self.assertEqual(
'Property privateProperty in class DerivedFrom2Classes '
'Property "privateProperty" in class "DerivedFrom2Classes" '
'cannot be written', str(e))
def test_access_ambiguous_property_with_resolver(self):
@ -73,7 +73,7 @@ class TestPropertyAccess(test_case.DslTestCase):
self._runner.on(self._multi_derived).
testAccessAmbiguousPropertyWithoutResolver)
self.assertEqual(
'Found more that one property ambiguousProperty1',
'Found more that one property "ambiguousProperty1"',
str(e))
def test_property_merge(self):
@ -91,7 +91,7 @@ class TestPropertyAccess(test_case.DslTestCase):
self._runner.on(self._multi_derived).
testModifyUsageTestProperty1)
self.assertEqual(
'Property usageTestProperty1 is immutable to the caller',
'Property "usageTestProperty1" is immutable to the caller',
str(e))
self.assertRaises(
exceptions.NoWriteAccessError,