Reformat evaluator #1
This commit is contained in:
@@ -1,2 +1,13 @@
|
||||
class SmnpException(Exception):
|
||||
pass
|
||||
def __init__(self, msg, pos):
|
||||
self.msg = msg
|
||||
self.pos = pos
|
||||
|
||||
def _title(self):
|
||||
pass
|
||||
|
||||
def _position(self):
|
||||
return "" if self.pos is None else f" [line {self.pos[0]+1}, col {self.pos[1]+1}]"
|
||||
|
||||
def message(self):
|
||||
return f"{self._title()}{self._position()}:\n{self.msg}"
|
||||
|
||||
@@ -2,20 +2,32 @@ from smnp.error.base import SmnpException
|
||||
|
||||
|
||||
class IllegalFunctionInvocationException(SmnpException):
|
||||
def __init__(self, expected, found):
|
||||
self.msg = f"Illegal function invocation\n\nExpected signature:\n{expected}\n\nFound:\n{found}"
|
||||
def __init__(self, expected, found, pos=None):
|
||||
super().__init__(f"Expected signature:\n{expected}\n\nFound:\n{found}", pos)
|
||||
|
||||
def _title(self):
|
||||
return "Invocation Error"
|
||||
|
||||
|
||||
class FunctionNotFoundException(SmnpException):
|
||||
def __init__(self, function):
|
||||
self.msg = f"Function '{function}' not found"
|
||||
def __init__(self, function, pos=None):
|
||||
super().__init__(f"Function '{function}' not found", pos)
|
||||
|
||||
def _title(self):
|
||||
return "Invocation Error"
|
||||
|
||||
|
||||
class MethodNotFoundException(SmnpException):
|
||||
def __init__(self, object, method):
|
||||
self.msg = f"Method '{method}' of type '{object}' not found"
|
||||
def __init__(self, object, method, pos=None):
|
||||
super().__init__(f"Method '{method}' of type '{object}' not found", pos)
|
||||
|
||||
def _title(self):
|
||||
return "Invocation Error"
|
||||
|
||||
|
||||
class IllegalArgumentException(SmnpException):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def __init__(self, msg, pos=None):
|
||||
super().__init__(msg, pos)
|
||||
|
||||
def _title(self):
|
||||
return "Argument Error"
|
||||
@@ -2,6 +2,12 @@ from smnp.error.base import SmnpException
|
||||
|
||||
|
||||
class RuntimeException(SmnpException):
|
||||
def __init__(self, pos, msg):
|
||||
posStr = "" if pos is None else f" [line {pos[0]+1}, col {pos[1]+1}]"
|
||||
self.msg = f"Runtime error{posStr}:\n{msg}"
|
||||
def __init__(self, msg, pos):
|
||||
super().__init__(msg, pos)
|
||||
|
||||
def _title(self):
|
||||
return "Runtime Error"
|
||||
|
||||
# def message(self):
|
||||
# posStr = "" if self.pos is None else f" [line {self.pos[0] + 1}, col {self.pos[1] + 1}]"
|
||||
# return f"Runtime error{posStr}:\n{self.mmsg}"
|
||||
|
||||
@@ -2,6 +2,9 @@ from smnp.error.base import SmnpException
|
||||
|
||||
|
||||
class SyntaxException(SmnpException):
|
||||
def __init__(self, pos, msg):
|
||||
posStr = "" if pos is None else f" [line {pos[0]+1}, col {pos[1]+1}]"
|
||||
self.msg = f"Syntax error{posStr}:\n{msg}"
|
||||
def __init__(self, msg, pos=None):
|
||||
super().__init__(msg, pos)
|
||||
|
||||
def _title(self):
|
||||
return "Syntax Error"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user