MISC: Show user-friendly error message when there is syntax error in scripts (#1963)

This commit is contained in:
catloversg
2025-02-16 16:27:26 +07:00
committed by GitHub
parent 0a4598a9a0
commit 23bc4e8804
3 changed files with 56 additions and 24 deletions
+2 -2
View File
@@ -146,7 +146,7 @@ function parseOnlyRamCalculate(
const scriptFileType = getFileType(script.filename);
let moduleAST;
try {
moduleAST = parseAST(script.code, scriptFileType);
moduleAST = parseAST(script.filename, script.server, script.code, scriptFileType);
} catch (error) {
return {
errorCode: RamCalculationErrorCode.ImportError,
@@ -552,7 +552,7 @@ export function calculateRamUsage(
): RamCalculation {
try {
const fileType = getFileType(scriptName);
const ast = typeof input === "string" ? parseAST(input, fileType) : input;
const ast = typeof input === "string" ? parseAST(scriptName, server, input, fileType) : input;
return parseOnlyRamCalculate(ast, scriptName, server, getFileTypeFeature(fileType), otherScripts);
} catch (error) {
return {