45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
# args
|
|
# 0) variable name
|
|
# 1) list of lines of the stack trace
|
|
|
|
class SPFException(Exception):
|
|
def __init__(self, *args):
|
|
super().__init__(*args)
|
|
self.msg = "Une erreur est survenue"
|
|
self.errorline = None
|
|
|
|
def __str__(self):
|
|
return (f"[ligne {self.errorline}] " if self.errorline else "") + f"{self.msg}"
|
|
|
|
class SPFSyntaxError(SPFException):
|
|
def __init__(self, *args):
|
|
super().__init__(*args)
|
|
self.msg = "Une erreur de syntaxe est survenue"
|
|
|
|
class SPFUnknownVariable(SPFException):
|
|
def __init__(self, *args):
|
|
super().__init__(*args)
|
|
self.msg = f"la variable `{args[0]}` n'est pas déclarée"
|
|
|
|
class SPFUninitializedVariable(SPFException):
|
|
def __init__(self, *args):
|
|
super().__init__(*args)
|
|
self.msg = f"la variable `{args[0]}` n'est pas initialisée"
|
|
|
|
class SPFAlreadyDefined(SPFException):
|
|
def __init__(self, *args):
|
|
super().__init__(*args)
|
|
self.msg = f"la variable `{args[0]}` est déjà déclarée"
|
|
|
|
class SPFIncompatibleType(SPFException):
|
|
def __init__(self, *args):
|
|
super().__init__(*args)
|
|
self.msg = f"`{args[0]}` n'est pas de type `{args[1]}`"
|
|
|
|
class SPFIndexError(SPFException):
|
|
def __init__(self, *args):
|
|
super().__init__(*args)
|
|
self.msg = f"La liste `{args[0]}` ne posède pas d'élèment d'indexe {args[1]}"
|
|
|
|
|