parameter -nrpv not fuctioning in toscaparser
[parser.git] / tosca2heat / tosca-parser / toscaparser / common / exception.py
index 4f99dda..d36a714 100644 (file)
@@ -20,7 +20,7 @@ import traceback
 from toscaparser.utils.gettextutils import _
 
 
-log = logging.getLogger(__name__)
+log = logging.getLogger('tosca')
 
 
 class TOSCAException(Exception):
@@ -67,6 +67,11 @@ class TOSCAException(Exception):
             TOSCAException._FATAL_EXCEPTION_FORMAT_ERRORS = flag
 
 
+class UnsupportedTypeError(TOSCAException):
+    msg_fmt = _('Type "%(what)s" is valid TOSCA type'
+                ' but not supported at this time.')
+
+
 class MissingRequiredFieldError(TOSCAException):
     msg_fmt = _('%(what)s is missing required field "%(required)s".')
 
@@ -88,6 +93,15 @@ class InvalidTypeError(TOSCAException):
     msg_fmt = _('Type "%(what)s" is not a valid type.')
 
 
+class InvalidTypeAdditionalRequirementsError(TOSCAException):
+    msg_fmt = _('Additional requirements for type "%(type)s" not met.')
+
+
+class RangeValueError(TOSCAException):
+    msg_fmt = _('The value "%(pvalue)s" of property "%(pname)s" is out of '
+                'range "(min:%(vmin)s, max:%(vmax)s)".')
+
+
 class InvalidSchemaError(TOSCAException):
     msg_fmt = _('%(message)s')
 
@@ -100,6 +114,30 @@ class UnknownInputError(TOSCAException):
     msg_fmt = _('Unknown input "%(input_name)s".')
 
 
+class UnknownOutputError(TOSCAException):
+    msg_fmt = _('Unknown output "%(output_name)s" in %(where)s.')
+
+
+class MissingRequiredInputError(TOSCAException):
+    msg_fmt = _('%(what)s is missing required input definition '
+                'of input "%(input_name)s".')
+
+
+class MissingRequiredParameterError(TOSCAException):
+    msg_fmt = _('%(what)s is missing required parameter for input '
+                '"%(input_name)s".')
+
+
+class MissingDefaultValueError(TOSCAException):
+    msg_fmt = _('%(what)s is missing required default value '
+                'of input "%(input_name)s".')
+
+
+class MissingRequiredOutputError(TOSCAException):
+    msg_fmt = _('%(what)s is missing required output definition '
+                'of output "%(output_name)s".')
+
+
 class InvalidPropertyValueError(TOSCAException):
     msg_fmt = _('Value of property "%(what)s" is invalid.')
 
@@ -167,6 +205,17 @@ class ExceptionCollector(object):
         else:
             raise exception
 
+    @staticmethod
+    def removeException(exception_type):
+        # if ExceptionCollector.collecting and ExceptionCollector.exceptions:
+        if ExceptionCollector.exceptions:
+            tmp_exceptions = []
+            for i, e in enumerate(ExceptionCollector.exceptions):
+                if not isinstance(e, exception_type):
+                    tmp_exceptions.append(e)
+                    # del ExceptionCollector.exceptions[i]
+            ExceptionCollector.exceptions = tmp_exceptions
+
     @staticmethod
     def exceptionsCaught():
         return len(ExceptionCollector.exceptions) > 0