From 638cce09d141a27627c6fa1aa65647df064a6eff Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 7 Oct 2008 21:59:56 +0000 Subject: Restore "friendly errors" to the XEngine --- .../ScriptEngine/Shared/Api/Runtime/Executor.cs | 17 ++++++++++------- .../Shared/CodeTools/CSCodeGenerator.cs | 13 +++++++++++-- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 21 +-------------------- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +- 4 files changed, 23 insertions(+), 30 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs index 43e3f3c..63ae6c7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs @@ -197,13 +197,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase } catch (TargetInvocationException tie) { - // Grab the inner exception and rethrow it, unless the inner - // exception is an EventAbortException as this indicates event - // invokation termination due to a state change. - if ( !(tie.InnerException is EventAbortException) ) - { - throw tie.InnerException; - } + // Grab the inner exception and rethrow it, unless the inner + // exception is an EventAbortException as this indicates event + // invocation termination due to a state change. + // DO NOT THROW JUST THE INNER EXCEPTION! + // FriendlyErrors depends on getting the whole exception! + // + if ( !(tie.InnerException is EventAbortException) ) + { + throw tie; + } } catch (Exception e) { diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index e8f2b71..a825eff 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -99,10 +99,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools string message; // LL start numbering lines at 0 - geeks! + // Also need to subtract one line we prepend! // + string emessage = e.Message; + string slinfo = e.slInfo.ToString(); + + // Remove wrong line number info + // + if (emessage.StartsWith(slinfo+": ")) + emessage = emessage.Substring(slinfo.Length+2); + message = String.Format("Line ({0},{1}) {2}", - e.slInfo.lineNumber - 1, - e.slInfo.charPosition - 1, e.Message); + e.slInfo.lineNumber - 2, + e.slInfo.charPosition - 1, emessage); throw new Exception(message); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index dcf3043..e39a0c2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -613,27 +613,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_InEvent = false; m_CurrentEvent = String.Empty; - if (!(e is TargetInvocationException) || (!(e.InnerException is EventAbortException) && (!(e.InnerException is SelfDeleteException)))) + if (!(e is TargetInvocationException) || !(e.InnerException is SelfDeleteException)) { - if (e is System.Threading.ThreadAbortException) - { - lock (m_EventQueue) - { - if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) - { - m_CurrentResult=m_Engine.QueueEventHandler(this); - } - else - { - m_CurrentResult = null; - } - } - - m_DetectParams = null; - - return 0; - } - try { // DISPLAY ERROR INWORLD diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 47f04d5..9b78d53 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -514,7 +514,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine try { // DISPLAY ERROR INWORLD - string text = "Error compiling script:\n" + e.ToString(); + string text = "Error compiling script:\n" + e.Message.ToString(); if (text.Length > 1000) text = text.Substring(0, 1000); World.SimChat(Utils.StringToBytes(text), -- cgit v1.1