Removal of script that was unable to compile no longer crashes server.

Displays script compile error messages in-world.
afrisby
Tedd Hansen 2007-08-25 20:34:54 +00:00
parent 65d6ef1bc1
commit 80234b98e5
3 changed files with 45 additions and 14 deletions

View File

@ -93,12 +93,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
// TODO: Return errors to user somehow // TODO: Return errors to user somehow
if (results.Errors.Count > 0) if (results.Errors.Count > 0)
{ {
string errtext = "";
foreach (CompilerError CompErr in results.Errors) foreach (CompilerError CompErr in results.Errors)
{ {
Console.WriteLine("Line number " + CompErr.Line + errtext += "Line number " + CompErr.Line +
", Error Number: " + CompErr.ErrorNumber + ", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + ";"); ", '" + CompErr.ErrorText + "'\r\n";
} }
throw new Exception(errtext);
} }

View File

@ -131,7 +131,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
{ {
// Add it to queue // 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[] { }); myScriptEngine.myEventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { });
// set next interval // set next interval

View File

@ -245,6 +245,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// It will be up to the script itself to hook up the correct events. // It will be up to the script itself to hook up the correct events.
string FileName = ""; string FileName = "";
IScriptHost m_host = World.GetSceneObjectPart(localID);
try try
{ {
@ -264,7 +266,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
long before; long before;
before = GC.GetTotalMemory(false); before = GC.GetTotalMemory(false);
#endif #endif
LSL_BaseClass CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName); LSL_BaseClass CompiledScript;
CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName);
#if DEBUG #if DEBUG
Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(false) - before); Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(false) - before);
#endif #endif
@ -274,7 +277,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// We need to give (untrusted) assembly a private instance of BuiltIns // 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. // 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 // Start the script - giving it BuiltIns
CompiledScript.Start(LSLB); CompiledScript.Start(LSLB);
@ -286,8 +291,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
catch (Exception e) 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 // Stop long command on script
m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID); m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID);
LSL_BaseClass LSLBC = GetScript(localID, itemID);
if (LSLBC == null)
return;
try
{
// Get AppDomain // Get AppDomain
AppDomain ad = GetScript(localID, itemID).Exec.GetAppDomain(); AppDomain ad = LSLBC.Exec.GetAppDomain();
// Tell script not to accept new requests // Tell script not to accept new requests
GetScript(localID, itemID).Exec.StopScript(); GetScript(localID, itemID).Exec.StopScript();
// Remove from internal structure // Remove from internal structure
RemoveScript(localID, itemID); RemoveScript(localID, itemID);
// Tell AppDomain that we have stopped script // Tell AppDomain that we have stopped script
m_scriptEngine.myAppDomainManager.StopScript(ad); 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) private string ProcessYield(string FileName)
{ {