# Copyright 2026 jCloud # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. class NamespaceError(ValueError): ''' Base class for namespace errors. ''' def __init__(self, *args: object, namespace_identifier: str = '') -> None: super().__init__(*args) self.namespace_identifier = namespace_identifier def __str__(self): if not self.args: return '' else: return f'{self.args[0]}{": " if self.namespace_identifier and self.args[0] else ""}{self.namespace_identifier if self.args[0] else ""}' class InvalidNamespaceError(NamespaceError): ... class NamespaceNotFoundError(NamespaceError): ... class NamespaceExistsError(NamespaceError): ... class PythonIdentifierError(ValueError): ''' Base class for Python identifier errors. ''' def __init__(self, *args: object, identifier: str = '') -> None: super().__init__(*args) self.identifier = identifier def __str__(self): if not self.args: return '' else: return f'{self.args[0]}{": " if self.identifier and self.args[0] else ""}{self.identifier if self.args[0] else ""}' class InvalidPythonIdentifierError(PythonIdentifierError): ... class PythonAnnotationError(ValueError): ''' Base class for Python annotation errors. ''' def __init__(self, *args: object, annotation: str = '') -> None: super().__init__(*args) self.annotation = annotation def __str__(self): if not self.args: return '' else: return f'{self.args[0]}{": " if self.annotation and self.args[0] else ""}{self.annotation if self.args[0] else ""}' class InvalidPythonAnnotationError(PythonAnnotationError): ... class PythonDefinitionError(ValueError): ''' Base class for Python definition errors. ''' def __init__(self, *args: object, definition: str = '') -> None: super().__init__(*args) self.definition = definition def __str__(self): if not self.args: return '' else: return f'{self.args[0]}{": " if self.definition and self.args[0] else ""}{self.definition if self.args[0] else ""}' class PythonArgumentStructureError(PythonDefinitionError): ...