FINALLY! Script compile errors now appear in the script error pane,

not in a funky debug window.
mysql-performance
Melanie 2009-12-22 09:24:01 +00:00
parent e68c7a1f23
commit 1876ce90af
5 changed files with 102 additions and 79 deletions

View File

@ -111,7 +111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
if (emessage.StartsWith(slinfo+": ")) if (emessage.StartsWith(slinfo+": "))
emessage = emessage.Substring(slinfo.Length+2); 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.lineNumber - 2,
e.slInfo.charPosition - 1, emessage); e.slInfo.charPosition - 1, emessage);

View File

@ -623,7 +623,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// The Second Life viewer's script editor begins // The Second Life viewer's script editor begins
// countingn lines and columns at 0, so we subtract 1. // 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, lslPos.Key - 1, lslPos.Value - 1,
CompErr.ErrorNumber, text, severity); CompErr.ErrorNumber, text, severity);
hadErrors = true; hadErrors = true;

View File

@ -1673,7 +1673,7 @@ default
{ {
// The syntax error is on line 6, char 5 (expected ';', found // 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; throw;
} }
} }
@ -1698,7 +1698,7 @@ default
catch (System.Exception e) catch (System.Exception e)
{ {
// The syntax error is on line 5, char 14 (Syntax error) // 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; throw;
} }

View File

@ -967,7 +967,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (col == 0) if (col == 0)
col++; col++;
message = string.Format("Runtime error:\n" + message = string.Format("Runtime error:\n" +
"Line ({0}): {1}", scriptLine - 1, "({0}): {1}", scriptLine - 1,
e.InnerException.Message); e.InnerException.Message);
System.Console.WriteLine(e.ToString()+"\n"); System.Console.WriteLine(e.ToString()+"\n");

View File

@ -77,6 +77,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
private string m_ScriptErrorMessage; private string m_ScriptErrorMessage;
private Dictionary<string, string> m_uniqueScripts = new Dictionary<string, string>(); private Dictionary<string, string> m_uniqueScripts = new Dictionary<string, string>();
private bool m_AppDomainLoading; private bool m_AppDomainLoading;
private Dictionary<UUID,ArrayList> m_ScriptErrors =
new Dictionary<UUID,ArrayList>();
// disable warning: need to keep a reference to XEngine.EventManager // disable warning: need to keep a reference to XEngine.EventManager
// alive to avoid it being garbage collected // alive to avoid it being garbage collected
@ -589,6 +591,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap; Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap;
lock(m_ScriptErrors)
{
try try
{ {
lock (m_AddingAssemblies) lock (m_AddingAssemblies)
@ -607,70 +611,78 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
foreach (string warning in warnings) foreach (string warning in warnings)
{ {
try if (!m_ScriptErrors.ContainsKey(itemID))
{ m_ScriptErrors[itemID] = new ArrayList();
// 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), m_ScriptErrors[itemID].Add(warning);
ChatTypeEnum.DebugChannel, 2147483647, // try
part.AbsolutePosition, // {
part.Name, part.UUID, false); // // DISPLAY WARNING INWORLD
} // string text = "Warning:\n" + warning;
} // if (text.Length > 1000)
catch (Exception e2) // LEGIT: User Scripting // text = text.Substring(0, 1000);
{ // if (!ShowScriptSaveResponse(item.OwnerID,
m_log.Error("[XEngine]: " + // assetID, text, true))
"Error displaying warning in-world: " + // {
e2.ToString()); // if (presence != null && (!postOnRez))
m_log.Error("[XEngine]: " + // presence.ControllingClient.SendAgentAlertMessage("Script saved with warnings, check debug window!", false);
"Warning:\r\n" + //
warning); // 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) catch (Exception e)
{ {
try // try
{ // {
if (!m_ScriptErrors.ContainsKey(itemID))
m_ScriptErrors[itemID] = new ArrayList();
// DISPLAY ERROR INWORLD // 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_ScriptErrorMessage += "Failed to compile script in object: '" + part.ParentGroup.RootPart.Name + "' Script name: '" + item.Name + "' Error message: " + e.Message.ToString();
//
m_ScriptFailCount++; m_ScriptFailCount++;
string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString(); m_ScriptErrors[itemID].Add(e.Message.ToString());
if (text.Length > 1000) // string text = "Error compiling script '" + item.Name + "':\n" + e.Message.ToString();
text = text.Substring(0, 1000); // if (text.Length > 1000)
if (!ShowScriptSaveResponse(item.OwnerID, // text = text.Substring(0, 1000);
assetID, text, false)) // if (!ShowScriptSaveResponse(item.OwnerID,
{ // assetID, text, false))
if (presence != null && (!postOnRez)) // {
presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false); // if (presence != null && (!postOnRez))
World.SimChat(Utils.StringToBytes(text), // presence.ControllingClient.SendAgentAlertMessage("Script saved with errors, check debug window!", false);
ChatTypeEnum.DebugChannel, 2147483647, // World.SimChat(Utils.StringToBytes(text),
part.AbsolutePosition, // ChatTypeEnum.DebugChannel, 2147483647,
part.Name, part.UUID, false); // part.AbsolutePosition,
} // part.Name, part.UUID, false);
} // }
catch (Exception e2) // LEGIT: User Scripting // }
{ // catch (Exception e2) // LEGIT: User Scripting
m_log.Error("[XEngine]: "+ // {
"Error displaying error in-world: " + // m_log.Error("[XEngine]: "+
e2.ToString()); // "Error displaying error in-world: " +
m_log.Error("[XEngine]: " + // e2.ToString());
"Errormessage: Error compiling script:\r\n" + // m_log.Error("[XEngine]: " +
e.Message.ToString()); // "Errormessage: Error compiling script:\r\n" +
} // e.Message.ToString());
// }
return false; return false;
} }
}
lock (m_Scripts) lock (m_Scripts)
{ {
@ -1473,7 +1485,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public ArrayList GetScriptErrors(UUID itemID) public ArrayList GetScriptErrors(UUID itemID)
{ {
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(); return new ArrayList();
} }
} }
}
} }