From 67ec95bde88d852df0f150dd55ea19456b4a070b Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Fri, 24 Jan 2014 15:32:12 -0800
Subject: Updated methods for handling LSL script errors, deprecated, and not
implemented
---
.../Shared/Api/Implementation/LSL_Api.cs | 65 +++++++++++++++++++---
1 file changed, 58 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index e54b697..1aa094b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -101,7 +101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
///
protected TaskInventoryItem m_item;
- protected bool throwErrorOnNotImplemented = true;
+ protected bool throwErrorOnNotImplemented = false;
protected AsyncCommandManager AsyncCommands = null;
protected float m_ScriptDelayFactor = 1.0f;
protected float m_ScriptDistanceFactor = 1.0f;
@@ -11245,20 +11245,71 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return item.ItemID;
}
- internal void ShoutError(string msg)
+ ///
+ /// Reports the script error in the viewer's Script Warning/Error dialog and shouts it on the debug channel.
+ ///
+ /// The name of the command that generated the error.
+ /// The error message to report to the user.
+ internal void Error(string command, string message)
{
- llShout(ScriptBaseClass.DEBUG_CHANNEL, msg);
+ string text = command + ": " + message;
+ if (text.Length > 1023)
+ {
+ text = text.Substring(0, 1023);
+ }
+
+ World.SimChat(Utils.StringToBytes(text), ChatTypeEnum.DebugChannel, ScriptBaseClass.DEBUG_CHANNEL,
+ m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, false);
+
+ IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface();
+ if (wComm != null)
+ {
+ wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, text);
+ }
}
- internal void NotImplemented(string command)
+ ///
+ /// Reports that the command is not implemented as a script error.
+ ///
+ /// The name of the command that is not implemented.
+ /// Additional information to report to the user. (Optional)
+ internal void NotImplemented(string command, string message = "")
{
if (throwErrorOnNotImplemented)
- throw new NotImplementedException("Command not implemented: " + command);
+ {
+ if (message != "")
+ {
+ message = " - " + message;
+ }
+
+ throw new NotImplementedException("Command not implemented: " + command + message);
+ }
+ else
+ {
+ string text = "Command not implemented";
+ if (message != "")
+ {
+ text = text + " - " + message;
+ }
+
+ Error(command, text);
+ }
}
- internal void Deprecated(string command)
+ ///
+ /// Reports that the command is deprecated as a script error.
+ ///
+ /// The name of the command that is deprecated.
+ /// Additional information to report to the user. (Optional)
+ internal void Deprecated(string command, string message = "")
{
- throw new ScriptException("Command deprecated: " + command);
+ string text = "Command deprecated";
+ if (message != "")
+ {
+ text = text + " - " + message;
+ }
+
+ Error(command, text);
}
internal void LSLError(string msg)
--
cgit v1.1