From 66e84f96be99d23ff3a06ced6c053766b73705cc Mon Sep 17 00:00:00 2001 From: Honkbinger <150275751+Honkbinger@users.noreply.github.com> Date: Fri, 27 Sep 2024 07:03:18 +0300 Subject: [PATCH 1/4] print(e.Message) => print(e) --- .../SharedSource/LuaCs/Plugins/CsPackageManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs index 8ba1f8921c..cd56238a98 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs @@ -831,7 +831,7 @@ private void TryRun(Action action, string messageMethodName, string messageTypeN catch (Exception e) { ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Error while running {messageMethodName}() on plugin of type {messageTypeName}"); - ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Details: {e.Message} | {e.InnerException}"); + ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Details: {e}"); } } From 7d17e58f1151fcb20da36426281745f30a570b2c Mon Sep 17 00:00:00 2001 From: Honkbinger <150275751+Honkbinger@users.noreply.github.com> Date: Fri, 27 Sep 2024 08:16:01 +0300 Subject: [PATCH 2/4] Print exception stack trace in CsPackageManager.TryRun --- .../SharedSource/LuaCs/Plugins/CsPackageManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs index cd56238a98..507ea8e9e1 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs @@ -830,8 +830,14 @@ private void TryRun(Action action, string messageMethodName, string messageTypeN } catch (Exception e) { + StackTrace st = new StackTrace(e); + String s = String.Join('\n', + st.GetFrames().SkipLast(1) + .Select(f => $"at {f.GetMethod().DeclaringType}.{f.GetMethod().Name}()") + ); + ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Error while running {messageMethodName}() on plugin of type {messageTypeName}"); - ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Details: {e}"); + ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Details: {e.Message}\n{s}"); } } From 6547106270abd0501252c6793e7f3062917be32b Mon Sep 17 00:00:00 2001 From: Honkbinger <150275751+Honkbinger@users.noreply.github.com> Date: Sat, 28 Sep 2024 21:40:00 +0300 Subject: [PATCH 3/4] added Inner Exception back --- .../SharedSource/LuaCs/Plugins/CsPackageManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs index 507ea8e9e1..d704b62cb4 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs @@ -833,11 +833,14 @@ private void TryRun(Action action, string messageMethodName, string messageTypeN StackTrace st = new StackTrace(e); String s = String.Join('\n', st.GetFrames().SkipLast(1) - .Select(f => $"at {f.GetMethod().DeclaringType}.{f.GetMethod().Name}()") + .Select(f => $" at {f.GetMethod().DeclaringType}.{f.GetMethod().Name}()") ); ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Error while running {messageMethodName}() on plugin of type {messageTypeName}"); ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Details: {e.Message}\n{s}"); + if(e.InnerException != null){ + ModUtils.Logging.PrintError($"{nameof(CsPackageManager)}: Inner Exception: {e.InnerException}"); + } } } From 2de0dbd7a810cab1aa326d3e9232950ecd0d69af Mon Sep 17 00:00:00 2001 From: Honkbinger <150275751+Honkbinger@users.noreply.github.com> Date: Sun, 29 Sep 2024 08:14:55 +0300 Subject: [PATCH 4/4] skip 2 frames Finally was able to compile luatrauma And stack trace seems to be 1 frame longer than in harmony patch also you need System.Diagnostics (kek) --- .../SharedSource/LuaCs/Plugins/CsPackageManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs index d704b62cb4..de2e2beea0 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/CsPackageManager.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Diagnostics; using System.Runtime.CompilerServices; using System.Text; using System.Threading; @@ -832,7 +833,7 @@ private void TryRun(Action action, string messageMethodName, string messageTypeN { StackTrace st = new StackTrace(e); String s = String.Join('\n', - st.GetFrames().SkipLast(1) + st.GetFrames().SkipLast(2) .Select(f => $" at {f.GetMethod().DeclaringType}.{f.GetMethod().Name}()") );