diff --git a/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs b/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs index 174509dc5b7..9abfda4538a 100644 --- a/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs +++ b/modules/mono/editor/GodotTools/GodotTools/CsProjOperations.cs @@ -81,7 +81,12 @@ namespace GodotTools } } - ScriptClassParser.ParseFileOrThrow(projectIncludeFile, out var classes); + Error parseError = ScriptClassParser.ParseFile(projectIncludeFile, out var classes, out string errorStr); + if (parseError != Error.Ok) + { + GD.PushError($"Failed to determine namespace and class for script: {projectIncludeFile}. Parse error: {errorStr ?? parseError.ToString()}"); + continue; + } string searchName = System.IO.Path.GetFileNameWithoutExtension(projectIncludeFile); diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs index 11afa8773ed..7fb087467f4 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Internals/ScriptClassParser.cs @@ -27,12 +27,15 @@ namespace GodotTools.Internals [MethodImpl(MethodImplOptions.InternalCall)] private static extern Error internal_ParseFile(string filePath, Array classes, out string errorStr); - public static void ParseFileOrThrow(string filePath, out IEnumerable classes) + public static Error ParseFile(string filePath, out IEnumerable classes, out string errorStr) { var classesArray = new Array(); - var error = internal_ParseFile(filePath, classesArray, out string errorStr); + var error = internal_ParseFile(filePath, classesArray, out errorStr); if (error != Error.Ok) - throw new Exception($"Failed to determine namespace and class for script: {filePath}. Parse error: {errorStr ?? error.ToString()}"); + { + classes = null; + return error; + } var classesList = new List(); @@ -47,6 +50,8 @@ namespace GodotTools.Internals } classes = classesList; + + return Error.Ok; } } }