Skip to content

Commit 0248672

Browse files
authored
Readability improvements of ScriptEngine.cs
- Use `var` - Removed curly brackets from foreach blocks. - Build the whole error message with one StringBuilder.
1 parent b460c6a commit 0248672

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Diff for: src/ScriptEngine/ScriptEngine.cs

+11-5
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,17 @@ void LoadDLL(string path, GameObject obj)
9797
}
9898
catch (ReflectionTypeLoadException e)
9999
{
100-
StringBuilder strTypes = new StringBuilder();
101-
foreach (var t in e.Types) { strTypes.Append(t + "\r\n"); }
102-
StringBuilder strExceptions = new StringBuilder();
103-
foreach (var l in e.LoaderExceptions) { strExceptions.Append(l + "\r\n"); }
104-
Logger.LogError($"Error While loading {path} \r\n -- Types --\r\n{strTypes}\r\n-- LoaderExceptions --\r\n{strExceptions}\r\n -- StackTrace --\r\n{e.StackTrace}");
100+
var sbMessage = new StringBuilder();
101+
sbMessage.AppendLine($"Error While loading {path}");
102+
sbMessage.AppendLine("-- Successfully Read Types --");
103+
foreach (var t in e.Types)
104+
if (t != null) sbMessage.AppendLine(t.ToString());
105+
sbMessage.AppendLine("\r\n-- LoaderExceptions --");
106+
foreach (var l in e.LoaderExceptions)
107+
if (l != null) sbMessage.AppendLine(l.ToString());
108+
sbMessage.AppendLine("\r\n-- StackTrace --");
109+
sbMessage.AppendLine(e.StackTrace);
110+
Logger.LogError(sbMessage.ToString());
105111
}
106112
}
107113
}

0 commit comments

Comments
 (0)