diff options
author | Melanie Thielker | 2008-09-27 05:31:43 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-09-27 05:31:43 +0000 |
commit | 85068dae60db02b168a29ffd75e1408e30d279e1 (patch) | |
tree | 8389c246a6e9891eb1bf310b85cba19a1668d790 /OpenSim/Region/ScriptEngine/Shared/Instance | |
parent | Mantis #2277 (diff) | |
download | opensim-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/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index c8d60af..aa9ace4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -80,6 +80,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
80 | private int m_ControlEventsInQueue = 0; | 80 | private int m_ControlEventsInQueue = 0; |
81 | private int m_LastControlLevel = 0; | 81 | private int m_LastControlLevel = 0; |
82 | private bool m_CollisionInQueue = false; | 82 | private bool m_CollisionInQueue = false; |
83 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | ||
84 | m_LineMap; | ||
85 | |||
86 | public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | ||
87 | LineMap | ||
88 | { | ||
89 | get { return m_LineMap; } | ||
90 | set { m_LineMap = value; } | ||
91 | } | ||
83 | 92 | ||
84 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); | 93 | private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); |
85 | 94 | ||
@@ -628,7 +637,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
628 | try | 637 | try |
629 | { | 638 | { |
630 | // DISPLAY ERROR INWORLD | 639 | // DISPLAY ERROR INWORLD |
631 | string text = "Runtime error:\n" + e.InnerException.ToString(); | 640 | string text = FormatException(e); |
641 | |||
632 | if (text.Length > 1000) | 642 | if (text.Length > 1000) |
633 | text = text.Substring(0, 1000); | 643 | text = text.Substring(0, 1000); |
634 | m_Engine.World.SimChat(Utils.StringToBytes(text), | 644 | m_Engine.World.SimChat(Utils.StringToBytes(text), |
@@ -812,5 +822,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
812 | { | 822 | { |
813 | return String.Format("{0} {1} on {2}", m_ScriptName, m_ItemID, m_PrimName); | 823 | return String.Format("{0} {1} on {2}", m_ScriptName, m_ItemID, m_PrimName); |
814 | } | 824 | } |
825 | |||
826 | string FormatException(Exception e) | ||
827 | { | ||
828 | string message = "Runtime error:\n" + e.InnerException.StackTrace; | ||
829 | string[] lines = message.Split(new char[] {'\n'}); | ||
830 | |||
831 | foreach (string line in lines) | ||
832 | { | ||
833 | if (line.Contains("SecondLife.Script")) | ||
834 | { | ||
835 | int idx = line.IndexOf(':'); | ||
836 | if (idx != -1) | ||
837 | { | ||
838 | string val = line.Substring(idx+1); | ||
839 | int lineNum = 0; | ||
840 | if (int.TryParse(val, out lineNum)) | ||
841 | { | ||
842 | KeyValuePair<int, int> pos = | ||
843 | Compiler.FindErrorPosition( | ||
844 | lineNum, 0, LineMap); | ||
845 | |||
846 | int scriptLine = pos.Key; | ||
847 | int col = pos.Value; | ||
848 | if (scriptLine == 0) | ||
849 | scriptLine++; | ||
850 | if (col == 0) | ||
851 | col++; | ||
852 | message = string.Format("Runtime error:\n" + | ||
853 | "Line ({0}): {1}", scriptLine - 1, | ||
854 | e.InnerException.Message); | ||
855 | |||
856 | return message; | ||
857 | } | ||
858 | } | ||
859 | } | ||
860 | } | ||
861 | |||
862 | return message; | ||
863 | } | ||
815 | } | 864 | } |
816 | } | 865 | } |