aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs92
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs5
3 files changed, 74 insertions, 30 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
index 634a12b..4a094e2 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
@@ -139,6 +139,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
139 public string functionName; 139 public string functionName;
140 public DetectParams[] llDetectParams; 140 public DetectParams[] llDetectParams;
141 public object[] param; 141 public object[] param;
142 public Dictionary<KeyValuePair<int,int>,KeyValuePair<int,int>>
143 LineMap;
142 } 144 }
143 145
144 #endregion 146 #endregion
@@ -349,6 +351,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
349 return false; 351 return false;
350 } 352 }
351 353
354 InstanceData id = m_ScriptEngine.m_ScriptManager.GetScript(
355 localID, itemID);
356
352 // Create a structure and add data 357 // Create a structure and add data
353 QueueItemStruct QIS = new QueueItemStruct(); 358 QueueItemStruct QIS = new QueueItemStruct();
354 QIS.localID = localID; 359 QIS.localID = localID;
@@ -356,6 +361,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
356 QIS.functionName = FunctionName; 361 QIS.functionName = FunctionName;
357 QIS.llDetectParams = qParams; 362 QIS.llDetectParams = qParams;
358 QIS.param = param; 363 QIS.param = param;
364 if (id != null)
365 QIS.LineMap = id.LineMap;
359 366
360 // Add it to queue 367 // Add it to queue
361 eventQueue.Enqueue(QIS); 368 eventQueue.Enqueue(QIS);
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
index 2d60ed5..16dafdc 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.Reflection; 31using System.Reflection;
31using System.Text.RegularExpressions; 32using System.Text.RegularExpressions;
32using System.Threading; 33using System.Threading;
@@ -37,6 +38,7 @@ using OpenSim.Framework;
37using OpenSim.Region.Environment.Scenes; 38using OpenSim.Region.Environment.Scenes;
38using OpenSim.Region.Environment.Scenes.Scripting; 39using OpenSim.Region.Environment.Scenes.Scripting;
39using OpenSim.Region.ScriptEngine.Shared; 40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.CodeTools;
40 42
41namespace OpenSim.Region.ScriptEngine.DotNetEngine 43namespace OpenSim.Region.ScriptEngine.DotNetEngine
42{ 44{
@@ -198,10 +200,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
198 } 200 }
199 catch (Exception e) 201 catch (Exception e)
200 { 202 {
201 if (lastScriptEngine != null)
202 lastScriptEngine.Log.Error("[" + ScriptEngineName +
203 "]: Exception in EventQueueThreadLoop: " +
204 e.ToString());
205 } 203 }
206 } 204 }
207 } 205 }
@@ -290,32 +288,32 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
290 catch (Exception e) 288 catch (Exception e)
291 { 289 {
292 InExecution = false; 290 InExecution = false;
291 string text = FormatException(e, QIS.LineMap);
292
293 // DISPLAY ERROR INWORLD 293 // DISPLAY ERROR INWORLD
294 string text = "Error executing script function \"" +
295 QIS.functionName + "\":\r\n";
296 294
297 if (e.InnerException != null) 295// if (e.InnerException != null)
298 { 296// {
299 // Send inner exception 297// // Send inner exception
300 string line = " (unknown line)"; 298// string line = " (unknown line)";
301 Regex rx = new Regex(@"SecondLife\.Script\..+[\s:](?<line>\d+)\.?\r?$", RegexOptions.Compiled); 299// Regex rx = new Regex(@"SecondLife\.Script\..+[\s:](?<line>\d+)\.?\r?$", RegexOptions.Compiled);
302 if (rx.Match(e.InnerException.ToString()).Success) 300// if (rx.Match(e.InnerException.ToString()).Success)
303 line = " (line " + rx.Match(e.InnerException.ToString()).Result("${line}") + ")"; 301// line = " (line " + rx.Match(e.InnerException.ToString()).Result("${line}") + ")";
304 text += e.InnerException.Message.ToString() + line; 302// text += e.InnerException.Message.ToString() + line;
305 } 303// }
306 else 304// else
307 { 305// {
308 text += "\r\n"; 306// text += "\r\n";
309 // Send normal 307// // Send normal
310 text += e.Message.ToString(); 308// text += e.Message.ToString();
311 } 309// }
312 if (KillCurrentScript) 310// if (KillCurrentScript)
313 text += "\r\nScript will be deactivated!"; 311// text += "\r\nScript will be deactivated!";
314 312
315 try 313 try
316 { 314 {
317 if (text.Length > 1500) 315 if (text.Length >= 1100)
318 text = text.Substring(0, 1500); 316 text = text.Substring(0, 1099);
319 IScriptHost m_host = 317 IScriptHost m_host =
320 m_ScriptEngine.World.GetSceneObjectPart(QIS.localID); 318 m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
321 m_ScriptEngine.World.SimChat( 319 m_ScriptEngine.World.SimChat(
@@ -343,10 +341,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
343 QIS.localID, QIS.itemID); 341 QIS.localID, QIS.itemID);
344 } 342 }
345 } 343 }
346
347 // Pass it on so it's displayed on the console
348 // and in the logs (mikem 2008.06.02).
349 throw e.InnerException;
350 } 344 }
351 finally 345 finally
352 { 346 {
@@ -358,5 +352,45 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
358 } 352 }
359 } 353 }
360 } 354 }
355
356 string FormatException(Exception e, Dictionary<KeyValuePair<int,int>,
357 KeyValuePair<int,int>> LineMap)
358 {
359 string message = "Runtime error:\n" + e.InnerException.StackTrace;
360 string[] lines = message.Split(new char[] {'\n'});
361
362 foreach (string line in lines)
363 {
364 if (line.Contains("SecondLife.Script"))
365 {
366 int idx = line.IndexOf(':');
367 if (idx != -1)
368 {
369 string val = line.Substring(idx+1);
370 int lineNum = 0;
371 if (int.TryParse(val, out lineNum))
372 {
373 KeyValuePair<int, int> pos =
374 Compiler.FindErrorPosition(
375 lineNum, 0, LineMap);
376
377 int scriptLine = pos.Key;
378 int col = pos.Value;
379 if (scriptLine == 0)
380 scriptLine++;
381 if (col == 0)
382 col++;
383 message = string.Format("Runtime error:\n" +
384 "Line ({0}): {1}", scriptLine - 1,
385 e.InnerException.Message);
386
387 return message;
388 }
389 }
390 }
391 }
392
393 return message;
394 }
361 } 395 }
362} 396}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 8329805..1c1dcf3 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -53,6 +53,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
53 public int StartParam; 53 public int StartParam;
54 public AppDomain AppDomain; 54 public AppDomain AppDomain;
55 public Dictionary<string, IScriptApi> Apis; 55 public Dictionary<string, IScriptApi> Apis;
56 public Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>>
57 LineMap;
56 } 58 }
57 59
58 public class ScriptManager 60 public class ScriptManager
@@ -159,6 +161,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
159 m_scriptEngine.m_AppDomainManager.LoadScript( 161 m_scriptEngine.m_AppDomainManager.LoadScript(
160 CompiledScriptFile, out id.AppDomain); 162 CompiledScriptFile, out id.AppDomain);
161 163
164 id.LineMap = LSLCompiler.LineMap();
162 id.Script = CompiledScript; 165 id.Script = CompiledScript;
163 id.Source = Script; 166 id.Source = Script;
164 id.StartParam = startParam; 167 id.StartParam = startParam;
@@ -212,7 +215,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
212 try 215 try
213 { 216 {
214 // DISPLAY ERROR INWORLD 217 // DISPLAY ERROR INWORLD
215 string text = "Error compiling script:\r\n" + 218 string text = "Error compiling script:\n" +
216 e.Message.ToString(); 219 e.Message.ToString();
217 if (text.Length > 1100) 220 if (text.Length > 1100)
218 text = text.Substring(0, 1099); 221 text = text.Substring(0, 1099);