Add 'source' to RuntimeException
This commit is contained in:
@@ -2,6 +2,7 @@ class SmnpException(Exception):
|
||||
def __init__(self, msg, pos):
|
||||
self.msg = msg
|
||||
self.pos = pos
|
||||
self.file = None
|
||||
|
||||
def _title(self):
|
||||
pass
|
||||
@@ -10,7 +11,10 @@ class SmnpException(Exception):
|
||||
return ""
|
||||
|
||||
def _position(self):
|
||||
return "" if self.pos is None else f" [line {self.pos[0]+1}, col {self.pos[1]+1}]"
|
||||
return "" if self.pos is None else f"[line {self.pos[0]+1}, col {self.pos[1]+1}]"
|
||||
|
||||
def _file(self):
|
||||
return "" if self.file is None else f"File: {self.file}"
|
||||
|
||||
def message(self):
|
||||
return f"{self._title()}{self._position()}:\n{self.msg}\n{self._postMessage()}"
|
||||
return f"{self._title()}\n{self._file()} {self._position()}\n\n{self.msg}\n{self._postMessage()}"
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
from smnp.error.base import SmnpException
|
||||
from smnp.error.runtime import RuntimeException
|
||||
|
||||
|
||||
class CustomException(SmnpException):
|
||||
class CustomException(RuntimeException):
|
||||
def __init__(self, message, pos):
|
||||
super().__init__(message, pos)
|
||||
|
||||
def _title(self):
|
||||
return "Execution Error"
|
||||
|
||||
def _postMessage(self):
|
||||
return "\n" + self.environment.callStackToString() if len(self.environment.callStack) > 0 else ""
|
||||
Reference in New Issue
Block a user