diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index f24eb63cb9..bdeed8f929 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -93,12 +93,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // TODO: Return errors to user somehow if (results.Errors.Count > 0) { + + string errtext = ""; foreach (CompilerError CompErr in results.Errors) { - Console.WriteLine("Line number " + CompErr.Line + + errtext += "Line number " + CompErr.Line + ", Error Number: " + CompErr.ErrorNumber + - ", '" + CompErr.ErrorText + ";"); + ", '" + CompErr.ErrorText + "'\r\n"; } + throw new Exception(errtext); } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs index e2c039c964..2395dbdc7e 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/LSLLongCmdHandler.cs @@ -131,7 +131,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) { // Add it to queue - //Console.WriteLine("Enqueue timer event: " + ts.next.ToUniversalTime().ToString("HH:mm:ss") + " > " + DateTime.Now.ToUniversalTime().ToString("HH:mm:ss")); myScriptEngine.myEventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { }); // set next interval diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 29171a19cb..bf863b8f84 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -245,6 +245,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // It will be up to the script itself to hook up the correct events. string FileName = ""; + IScriptHost m_host = World.GetSceneObjectPart(localID); + try { @@ -264,7 +266,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine long before; before = GC.GetTotalMemory(false); #endif - LSL_BaseClass CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName); + LSL_BaseClass CompiledScript; + CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName); #if DEBUG Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(false) - before); #endif @@ -274,7 +277,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // We need to give (untrusted) assembly a private instance of BuiltIns // this private copy will contain Read-Only FullitemID so that it can bring that on to the server whenever needed. - LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, World.GetSceneObjectPart(localID), localID, itemID); + + + LSL_BuiltIn_Commands LSLB = new LSL_BuiltIn_Commands(m_scriptEngine, m_host, localID, itemID); // Start the script - giving it BuiltIns CompiledScript.Start(LSLB); @@ -286,8 +291,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } catch (Exception e) { - m_scriptEngine.Log.Error("ScriptEngine", "Exception loading script \"" + FileName + "\": " + e.ToString()); + m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString()); + try + { + // DISPLAY ERROR INWORLD + string text = "Error compiling script:\r\n" + e.Message.ToString(); + if (text.Length > 1500) + text = text.Substring(0, 1500); + World.SimChat(Helpers.StringToField(text), 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID); + } + catch (Exception e2) + { + m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString()); + } } + } @@ -300,14 +318,25 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Stop long command on script m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID); - // Get AppDomain - AppDomain ad = GetScript(localID, itemID).Exec.GetAppDomain(); - // Tell script not to accept new requests - GetScript(localID, itemID).Exec.StopScript(); - // Remove from internal structure - RemoveScript(localID, itemID); - // Tell AppDomain that we have stopped script - m_scriptEngine.myAppDomainManager.StopScript(ad); + LSL_BaseClass LSLBC = GetScript(localID, itemID); + if (LSLBC == null) + return; + + try + { + // Get AppDomain + AppDomain ad = LSLBC.Exec.GetAppDomain(); + // Tell script not to accept new requests + GetScript(localID, itemID).Exec.StopScript(); + // Remove from internal structure + RemoveScript(localID, itemID); + // Tell AppDomain that we have stopped script + m_scriptEngine.myAppDomainManager.StopScript(ad); + } + catch(Exception e) + { + Console.WriteLine("Exception stopping script localID: " + localID + " LLUID: " + itemID.ToString() + ": " + e.ToString()); + } } private string ProcessYield(string FileName) {