MCPcopy Index your code
hub / github.com/MCSLTeam/MCSL2 / error

Method error

MCSL2Lib/ProgramControllers/logController.py:95–111  ·  view source on GitHub ↗
(self, exc: Optional[Exception] = None, msg: Optional[str] = "")

Source from the content-addressed store, hash-verified

93 self.logger.success(self._template(caller_info, msg))
94
95 def error(self, exc: Optional[Exception] = None, msg: Optional[str] = ""):
96 frame = getframeinfo(currentframe().f_back)
97 caller_info = {
98 "module": getmodulename(frame.filename),
99 "filename": frame.filename,
100 "line": frame.lineno,
101 "function": frame.function,
102 }
103 excStr = ""
104 if exc is not None:
105 # 确保 exc 是异常对象,而不是字符串
106 if isinstance(exc, BaseException):
107 excStr = "".join(format_exception(type(exc), exc, exc.__traceback__))
108 else:
109 # 如果 exc 不是异常对象,只记录其字符串表示
110 excStr = str(exc)
111 self.logger.error(self._template(caller_info, f"{msg}\n{excStr}"))
112
113 def trace(self, msg: str):
114 frame = getframeinfo(currentframe().f_back)

Callers 15

deletePluginFileMethod · 0.45
autoStartServersMethod · 0.45
catchExceptionsMethod · 0.45
initializeMCSL2Function · 0.45
onDownloadFinishedMethod · 0.45
onDownloadFinishedMethod · 0.45
addJavaManuallyMethod · 0.45
finishBedrockServerMethod · 0.45
_saveJavaServerAsyncMethod · 0.45

Calls 1

_templateMethod · 0.95

Tested by

no test coverage detected