diff --git a/Sources/Sandbox.Game/Game/Entities/Blocks/MyProgrammableBlock.cs b/Sources/Sandbox.Game/Game/Entities/Blocks/MyProgrammableBlock.cs index d3f883ed0d..eb96a037c7 100644 --- a/Sources/Sandbox.Game/Game/Entities/Blocks/MyProgrammableBlock.cs +++ b/Sources/Sandbox.Game/Game/Entities/Blocks/MyProgrammableBlock.cs @@ -181,11 +181,6 @@ bool IMyProgrammableBlock.TryRun(string argument) return false; } - if (!IsFunctional || !IsWorking) - { - return false; - } - string response; var result = this.ExecuteCode(argument ?? "", out response); SetDetailedInfo(response); @@ -461,6 +456,20 @@ public ScriptTerminationReason RunSandboxedProgramAction(Action } } else { response += MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Exception_ExceptionCaught) + ex.Message; + + // Get both StackTraces + StringBuilder ExceptionStackTrace = new StringBuilder(ex.StackTrace); + string[] currentStackTrace = Environment.StackTrace.Split(new string[] {Environment.NewLine}, StringSplitOptions.None); + + // Remove All internal calls before the Script Call + for (int i = 0; i < currentStackTrace.Length; i++) + { + ExceptionStackTrace.Replace(currentStackTrace[i], ""); + } + + // Add Script StackTrace to response Line + response += "\n" + ExceptionStackTrace.ToString(); + OnProgramTermination(ScriptTerminationReason.RuntimeException); } return m_terminationReason;