aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
diff options
context:
space:
mode:
authorMelanie Thielker2008-09-27 05:31:43 +0000
committerMelanie Thielker2008-09-27 05:31:43 +0000
commit85068dae60db02b168a29ffd75e1408e30d279e1 (patch)
tree8389c246a6e9891eb1bf310b85cba19a1668d790 /OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
parentMantis #2277 (diff)
downloadopensim-SC-85068dae60db02b168a29ffd75e1408e30d279e1.zip
opensim-SC-85068dae60db02b168a29ffd75e1408e30d279e1.tar.gz
opensim-SC-85068dae60db02b168a29ffd75e1408e30d279e1.tar.bz2
opensim-SC-85068dae60db02b168a29ffd75e1408e30d279e1.tar.xz
Add friendly error messages to both engines.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs92
1 files changed, 63 insertions, 29 deletions
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}