diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index e427f50bac..b1fb6c2810 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -111,7 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools if (emessage.StartsWith(slinfo+": ")) emessage = emessage.Substring(slinfo.Length+2); - message = String.Format("Line ({0},{1}) {2}", + message = String.Format("({0},{1}) {2}", e.slInfo.lineNumber - 2, e.slInfo.charPosition - 1, emessage); diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 3080c711b0..d8c0ba57a5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -623,7 +623,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools // The Second Life viewer's script editor begins // countingn lines and columns at 0, so we subtract 1. - errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n", + errtext += String.Format("({0},{1}): {4} {2}: {3}\n", lslPos.Key - 1, lslPos.Value - 1, CompErr.ErrorNumber, text, severity); hadErrors = true; diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs index 3ca7f7ccc8..63afb0b111 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs @@ -1673,7 +1673,7 @@ default { // The syntax error is on line 6, char 5 (expected ';', found // '}'). - Assert.AreEqual("Line (4,4) syntax error", e.Message); + Assert.AreEqual("(4,4) syntax error", e.Message); throw; } } @@ -1698,7 +1698,7 @@ default catch (System.Exception e) { // The syntax error is on line 5, char 14 (Syntax error) - Assert.AreEqual("Line (3,13) syntax error", e.Message); + Assert.AreEqual("(3,13) syntax error", e.Message); throw; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 5c5d57e817..d30d2dcacc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -967,7 +967,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (col == 0) col++; message = string.Format("Runtime error:\n" + - "Line ({0}): {1}", scriptLine - 1, + "({0}): {1}", scriptLine - 1, e.InnerException.Message); System.Console.WriteLine(e.ToString()+"\n"); diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 035686ed59..11b02e178b 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -77,6 +77,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine private string m_ScriptErrorMessage; private Dictionary m_uniqueScripts = new Dictionary(); private bool m_AppDomainLoading; + private Dictionary m_ScriptErrors = + new Dictionary(); // disable warning: need to keep a reference to XEngine.EventManager // alive to avoid it being garbage collected @@ -589,87 +591,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine Dictionary, KeyValuePair> linemap; - try - { - lock (m_AddingAssemblies) - { - m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); - if (!m_AddingAssemblies.ContainsKey(assembly)) { - m_AddingAssemblies[assembly] = 1; - } else { - m_AddingAssemblies[assembly]++; - } - } - - string[] warnings = m_Compiler.GetWarnings(); - - if (warnings != null && warnings.Length != 0) - { - foreach (string warning in warnings) - { - try - { - // DISPLAY WARNING INWORLD - string text = "Warning:\n" + warning; - if (text.Length > 1000) - text = text.Substring(0, 1000); - if (!ShowScriptSaveResponse(item.OwnerID, - assetID, text, true)) - { - if (presence != null && (!postOnRez)) - presence.ControllingClient.SendAgentAlertMessage("Script saved with warnings, check debug window!", false); - - World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - part.AbsolutePosition, - part.Name, part.UUID, false); - } - } - catch (Exception e2) // LEGIT: User Scripting - { - m_log.Error("[XEngine]: " + - "Error displaying warning in-world: " + - e2.ToString()); - m_log.Error("[XEngine]: " + - "Warning:\r\n" + - warning); - } - } - } - } - catch (Exception e) + lock(m_ScriptErrors) { try { - // DISPLAY ERROR INWORLD - m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString(); - - m_ScriptFailCount++; - string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString(); - if (text.Length > 1000) - text = text.Substring(0, 1000); - if (!ShowScriptSaveResponse(item.OwnerID, - assetID, text, false)) + lock (m_AddingAssemblies) { - if (presence != null && (!postOnRez)) - presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false); - World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - part.AbsolutePosition, - part.Name, part.UUID, false); + m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); + if (!m_AddingAssemblies.ContainsKey(assembly)) { + m_AddingAssemblies[assembly] = 1; + } else { + m_AddingAssemblies[assembly]++; + } + } + + string[] warnings = m_Compiler.GetWarnings(); + + if (warnings != null && warnings.Length != 0) + { + foreach (string warning in warnings) + { + if (!m_ScriptErrors.ContainsKey(itemID)) + m_ScriptErrors[itemID] = new ArrayList(); + + m_ScriptErrors[itemID].Add(warning); + // try + // { + // // DISPLAY WARNING INWORLD + // string text = "Warning:\n" + warning; + // if (text.Length > 1000) + // text = text.Substring(0, 1000); + // if (!ShowScriptSaveResponse(item.OwnerID, + // assetID, text, true)) + // { + // if (presence != null && (!postOnRez)) + // presence.ControllingClient.SendAgentAlertMessage("Script saved with warnings, check debug window!", false); + // + // World.SimChat(Utils.StringToBytes(text), + // ChatTypeEnum.DebugChannel, 2147483647, + // part.AbsolutePosition, + // part.Name, part.UUID, false); + // } + // } + // catch (Exception e2) // LEGIT: User Scripting + // { + // m_log.Error("[XEngine]: " + + // "Error displaying warning in-world: " + + // e2.ToString()); + // m_log.Error("[XEngine]: " + + // "Warning:\r\n" + + // warning); + // } + } } } - catch (Exception e2) // LEGIT: User Scripting + catch (Exception e) { - m_log.Error("[XEngine]: "+ - "Error displaying error in-world: " + - e2.ToString()); - m_log.Error("[XEngine]: " + - "Errormessage: Error compiling script:\r\n" + - e.Message.ToString()); - } + // try + // { + if (!m_ScriptErrors.ContainsKey(itemID)) + m_ScriptErrors[itemID] = new ArrayList(); + // DISPLAY ERROR INWORLD + // m_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString(); + // + m_ScriptFailCount++; + m_ScriptErrors[itemID].Add(e.Message.ToString()); + // string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString(); + // if (text.Length > 1000) + // text = text.Substring(0, 1000); + // if (!ShowScriptSaveResponse(item.OwnerID, + // assetID, text, false)) + // { + // if (presence != null && (!postOnRez)) + // presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false); + // World.SimChat(Utils.StringToBytes(text), + // ChatTypeEnum.DebugChannel, 2147483647, + // part.AbsolutePosition, + // part.Name, part.UUID, false); + // } + // } + // catch (Exception e2) // LEGIT: User Scripting + // { + // m_log.Error("[XEngine]: "+ + // "Error displaying error in-world: " + + // e2.ToString()); + // m_log.Error("[XEngine]: " + + // "Errormessage: Error compiling script:\r\n" + + // e.Message.ToString()); + // } - return false; + return false; + } } lock (m_Scripts) @@ -1473,7 +1485,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine public ArrayList GetScriptErrors(UUID itemID) { - return new ArrayList(); + System.Threading.Thread.Sleep(1000); + + lock (m_ScriptErrors) + { + if (m_ScriptErrors.ContainsKey(itemID)) + { + ArrayList ret = m_ScriptErrors[itemID]; + m_ScriptErrors.Remove(itemID); + return ret; + } + return new ArrayList(); + } } } }