"""An exception class representing a language error condition."""fromattrimportattrib,attrs,validators
[docs]@attrs(slots=True)classLanguageError(Exception):"""A base class representing a language error."""message:str=attrib(validator=validators.instance_of(str))location:str=attrib(validator=validators.instance_of(str))def__init__(self,message:str,location:str):""" An init constructor for the Language Error Class. Args: message (str): The error message. location (str): The source location of the error. """self.message=messageself.location=location
[docs]def__str__(self)->str:""" Method for defining how Language Error looks when represented as a string. Returns: The Language Error represented as a string. """returnf"Error: {self.message}. Location: {self.location}"