diff --git a/stix2/exceptions.py b/stix2/exceptions.py index 3043047..7fa76c4 100644 --- a/stix2/exceptions.py +++ b/stix2/exceptions.py @@ -150,3 +150,29 @@ class RevokeError(STIXError, ValueError): return "Cannot revoke an already revoked object." else: return "Cannot create a new version of a revoked object." + + +class InvalidSelectorError(STIXError, ValueError): + """Granular Marking selector violation. The selector must resolve into an existing STIX object property.""" + + def __init__(self, cls, key): + super(InvalidSelectorError, self).__init__() + self.cls = cls + self.key = key + + def __str__(self): + msg = "Selector '{0}' in '{1}' is not valid!" + return msg.format(self.key, self.__class__.__name__) + + +class InvalidMarkingError(STIXError, ValueError): + """Marking violation. The marking reference must be a valid identifier.""" + + def __init__(self, cls, key): + super(InvalidMarkingError, self).__init__() + self.cls = cls + self.key = key + + def __str__(self): + msg = "Marking '{0}' in '{1}' is not a valid marking reference." + return msg.format(self.key, self.__class__.__name__)