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')
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
From 13bb9ea6826f9141704c1baf9f2366ae38c06245 Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Fri, 24 Jan 2014 15:44:12 -0800
Subject: Updated ShoutError() calls to use new LSL error methods
---
.../Shared/Api/Implementation/LSL_Api.cs | 65 +++++++++-------------
1 file changed, 27 insertions(+), 38 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 1aa094b..f56010a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -261,7 +261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((item = GetScriptByName(name)) != UUID.Zero)
m_ScriptEngine.ResetScript(item);
else
- ShoutError("llResetOtherScript: script "+name+" not found");
+ Error("llResetOtherScript", "Script " + name + " not found");
}
public LSL_Integer llGetScriptState(string name)
@@ -275,7 +275,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return m_ScriptEngine.GetScriptState(item) ?1:0;
}
- ShoutError("llGetScriptState: script "+name+" not found");
+ Error("llGetScriptState", "Script " + name + " not found");
// If we didn't find it, then it's safe to
// assume it is not running.
@@ -298,7 +298,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else
{
- ShoutError("llSetScriptState: script "+name+" not found");
+ Error("llSetScriptState", "Script " + name + " not found");
}
}
@@ -3320,7 +3320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface();
if (emailModule == null)
{
- ShoutError("llEmail: email module not configured");
+ Error("llEmail", "Email module not configured");
return;
}
@@ -3334,7 +3334,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface();
if (emailModule == null)
{
- ShoutError("llGetNextEmail: email module not configured");
+ Error("llGetNextEmail", "Email module not configured");
return;
}
Email email;
@@ -3734,7 +3734,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission)
{
- ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
+ Error("llCreateLink", "PERMISSION_CHANGE_LINKS permission not set");
return;
}
@@ -3789,7 +3789,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission)
{
- ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
+ Error("llBreakLink", "PERMISSION_CHANGE_LINKS permission not set");
return;
}
@@ -4403,11 +4403,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (message == string.Empty)
{
- ShoutError("Trying to use llTextBox with empty message.");
+ Error("llTextBox", "Empty message");
}
else if (message.Length > 512)
{
- ShoutError("Trying to use llTextBox with message over 512 characters.");
+ Error("llTextBox", "Message more than 512 characters");
}
else
{
@@ -6861,15 +6861,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0);
}
- ///
- /// This is a depecated function so this just replicates the result of
- /// invoking it in SL
- ///
public void llRemoteLoadScript(string target, string name, int running, int start_param)
{
m_host.AddScriptLPS(1);
- // Report an error as it does in SL
- ShoutError("Deprecated. Please use llRemoteLoadScriptPin instead.");
+ Deprecated("llRemoteLoadScript", "Use llRemoteLoadScriptPin instead");
ScriptSleep(3000);
}
@@ -7951,9 +7946,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
catch (InvalidCastException e)
{
- ShoutError(string.Format(
- "{0} error running rule #{1}: arg #{2} ",
- originFunc, rulesParsed, idx - idxStart) + e.Message);
+ Error(originFunc, string.Format("Error running rule #{0}: arg #{1} - ", rulesParsed, idx - idxStart) + e.Message);
}
finally
{
@@ -10050,7 +10043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
presence = World.GetScenePresence(agentID);
}
}
- else ShoutError("The argument of PARCEL_MEDIA_COMMAND_AGENT must be a key");
+ else Error("llParcelMediaCommandList", "The argument of PARCEL_MEDIA_COMMAND_AGENT must be a key");
++i;
}
break;
@@ -10081,7 +10074,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
url = (LSL_String)commandList.Data[i + 1];
update = true;
}
- else ShoutError("The argument of PARCEL_MEDIA_COMMAND_URL must be a string.");
+ else Error("llParcelMediaCommandList", "The argument of PARCEL_MEDIA_COMMAND_URL must be a string");
++i;
}
break;
@@ -10094,7 +10087,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
texture = (LSL_String)commandList.Data[i + 1];
update = true;
}
- else ShoutError("The argument of PARCEL_MEDIA_COMMAND_TEXTURE must be a string or key.");
+ else Error("llParcelMediaCommandList", "The argument of PARCEL_MEDIA_COMMAND_TEXTURE must be a string or a key");
++i;
}
break;
@@ -10106,7 +10099,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
time = (float)(LSL_Float)commandList.Data[i + 1];
}
- else ShoutError("The argument of PARCEL_MEDIA_COMMAND_TIME must be a float.");
+ else Error("llParcelMediaCommandList", "The argument of PARCEL_MEDIA_COMMAND_TIME must be a float");
++i;
}
break;
@@ -10120,7 +10113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
update = true;
}
- else ShoutError("The argument of PARCEL_MEDIA_COMMAND_AUTO_ALIGN must be an integer.");
+ else Error("llParcelMediaCommandList", "The argument of PARCEL_MEDIA_COMMAND_AUTO_ALIGN must be an integer");
++i;
}
break;
@@ -10133,7 +10126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
mediaType = (LSL_String)commandList.Data[i + 1];
update = true;
}
- else ShoutError("The argument of PARCEL_MEDIA_COMMAND_TYPE must be a string.");
+ else Error("llParcelMediaCommandList", "The argument of PARCEL_MEDIA_COMMAND_TYPE must be a string");
++i;
}
break;
@@ -10146,7 +10139,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
description = (LSL_String)commandList.Data[i + 1];
update = true;
}
- else ShoutError("The argument of PARCEL_MEDIA_COMMAND_DESC must be a string.");
+ else Error("llParcelMediaCommandList", "The argument of PARCEL_MEDIA_COMMAND_DESC must be a string");
++i;
}
break;
@@ -10162,9 +10155,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
height = (LSL_Integer)commandList.Data[i + 2];
update = true;
}
- else ShoutError("The second argument of PARCEL_MEDIA_COMMAND_SIZE must be an integer.");
+ else Error("llParcelMediaCommandList", "The second argument of PARCEL_MEDIA_COMMAND_SIZE must be an integer");
}
- else ShoutError("The first argument of PARCEL_MEDIA_COMMAND_SIZE must be an integer.");
+ else Error("llParcelMediaCommandList", "The first argument of PARCEL_MEDIA_COMMAND_SIZE must be an integer");
i += 2;
}
break;
@@ -10336,7 +10329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{
- ShoutError("No permissions to track the camera");
+ Error("llGetCameraPos", "No permissions to track the camera");
return Vector3.Zero;
}
@@ -10359,7 +10352,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{
- ShoutError("No permissions to track the camera");
+ Error("llGetCameraRot", "No permissions to track the camera");
return Quaternion.Identity;
}
@@ -10382,14 +10375,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(2000);
}
- ///
- /// The SL implementation shouts an error, it is deprecated
- /// This duplicates SL
- ///
public void llRefreshPrimURL()
{
m_host.AddScriptLPS(1);
- ShoutError("llRefreshPrimURL - not yet supported");
+ Deprecated("llRefreshPrimURL");
ScriptSleep(20000);
}
@@ -11346,7 +11335,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (assetID == UUID.Zero)
{
// => complain loudly, as specified by the LSL docs
- ShoutError("Notecard '" + name + "' could not be found.");
+ Error("llGetNumberOfNotecardLines", "Notecard '" + name + "' could not be found");
return UUID.Zero.ToString();
}
@@ -11368,7 +11357,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (a == null || a.Type != 7)
{
- ShoutError("Notecard '" + name + "' could not be found.");
+ Error("llGetNumberOfNotecardLines", "Notecard '" + name + "' could not be found");
return;
}
@@ -11399,7 +11388,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (assetID == UUID.Zero)
{
// => complain loudly, as specified by the LSL docs
- ShoutError("Notecard '" + name + "' could not be found.");
+ Error("llGetNotecardLine", "Notecard '" + name + "' could not be found");
return UUID.Zero.ToString();
}
@@ -11422,7 +11411,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (a == null || a.Type != 7)
{
- ShoutError("Notecard '" + name + "' could not be found.");
+ Error("llGetNotecardLine", "Notecard '" + name + "' could not be found");
return;
}
--
cgit v1.1
From 257f9cec40786175157f8bfed7232b6532eabd5f Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Fri, 24 Jan 2014 16:34:01 -0800
Subject: Updated "not implemented" LSL errors to use NotImplemented()
---
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index f56010a..6b203ab 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3053,7 +3053,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llStopLookAt()
{
m_host.AddScriptLPS(1);
-// NotImplemented("llStopLookAt");
m_host.StopLookAt();
}
@@ -3419,7 +3418,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
catch (NotImplementedException)
{
// Currently not implemented in DotNetEngine only XEngine
- NotImplemented("llMinEventDelay in DotNetEngine");
+ NotImplemented("llMinEventDelay", "In DotNetEngine");
}
}
@@ -10163,7 +10162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
default:
- NotImplemented("llParcelMediaCommandList parameter not supported yet: " + Enum.Parse(typeof(ParcelMediaCommandEnum), commandList.Data[i].ToString()).ToString());
+ NotImplemented("llParcelMediaCommandList", "Parameter not supported yet: " + Enum.Parse(typeof(ParcelMediaCommandEnum), commandList.Data[i].ToString()).ToString());
break;
}//end switch
}//end for
@@ -10271,7 +10270,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
default:
ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url;
- NotImplemented("llParcelMediaQuery parameter do not supported yet: " + Enum.Parse(mediaCommandEnum.GetType() , aList.Data[i].ToString()).ToString());
+ NotImplemented("llParcelMediaQuery", "Parameter not supported yet: " + Enum.Parse(mediaCommandEnum.GetType() , aList.Data[i].ToString()).ToString());
break;
}
--
cgit v1.1
From c9550e473d7c9ec64d1cbffc8005f03a1aef13db Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Fri, 24 Jan 2014 16:46:10 -0800
Subject: Updated "deprecated" LSL errors to use Deprecrated()
---
.../Shared/Api/Implementation/LSL_Api.cs | 30 ++++++++--------------
1 file changed, 11 insertions(+), 19 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6b203ab..33dd77f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2553,9 +2553,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSound(string sound, double volume, int queue, int loop)
{
m_host.AddScriptLPS(1);
- // This function has been deprecated
- // see http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSound
- Deprecated("llSound");
+ Deprecated("llSound", "Use llPlaySound instead");
}
// Xantor 20080528 PlaySound updated so it accepts an objectinventory name -or- a key to a sound
@@ -2914,28 +2912,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llMakeExplosion(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- Deprecated("llMakeExplosion");
+ Deprecated("llMakeExplosion", "Use llParticleSystem instead");
ScriptSleep(100);
}
public void llMakeFountain(int particles, double scale, double vel, double lifetime, double arc, int bounce, string texture, LSL_Vector offset, double bounce_offset)
{
m_host.AddScriptLPS(1);
- Deprecated("llMakeFountain");
+ Deprecated("llMakeFountain", "Use llParticleSystem instead");
ScriptSleep(100);
}
public void llMakeSmoke(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- Deprecated("llMakeSmoke");
+ Deprecated("llMakeSmoke", "Use llParticleSystem instead");
ScriptSleep(100);
}
public void llMakeFire(int particles, double scale, double vel, double lifetime, double arc, string texture, LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- Deprecated("llMakeFire");
+ Deprecated("llMakeFire", "Use llParticleSystem instead");
ScriptSleep(100);
}
@@ -3236,13 +3234,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llTakeCamera(string avatar)
{
m_host.AddScriptLPS(1);
- Deprecated("llTakeCamera");
+ Deprecated("llTakeCamera", "Use llSetCameraParams instead");
}
public void llReleaseCamera(string avatar)
{
m_host.AddScriptLPS(1);
- Deprecated("llReleaseCamera");
+ Deprecated("llReleaseCamera", "Use llClearCameraParams instead");
}
public LSL_String llGetOwner()
@@ -3422,13 +3420,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- ///
- /// llSoundPreload is deprecated. In SL this appears to do absolutely nothing
- /// and is documented to have no delay.
- ///
public void llSoundPreload(string sound)
{
m_host.AddScriptLPS(1);
+ Deprecated("llSoundPreload", "Use llPreloadSound instead");
}
public void llRotLookAt(LSL_Rotation target, double strength, double damping)
@@ -8000,7 +7995,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_String llXorBase64Strings(string str1, string str2)
{
m_host.AddScriptLPS(1);
- Deprecated("llXorBase64Strings");
+ Deprecated("llXorBase64Strings", "Use llXorBase64 instead");
ScriptSleep(300);
return String.Empty;
}
@@ -8008,7 +8003,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llRemoteDataSetRegion()
{
m_host.AddScriptLPS(1);
- Deprecated("llRemoteDataSetRegion");
+ Deprecated("llRemoteDataSetRegion", "Use llOpenRemoteDataChannel instead");
}
public LSL_Float llLog10(double val)
@@ -10364,13 +10359,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return Quaternion.Identity;
}
- ///
- /// The SL implementation does nothing, it is deprecated
- /// This duplicates SL
- ///
public void llSetPrimURL(string url)
{
m_host.AddScriptLPS(1);
+ Deprecated("llSetPrimURL", "Use llSetPrimMediaParams instead");
ScriptSleep(2000);
}
--
cgit v1.1
From 9db4090c0771a28e8b9591f7403b28b7fe06a1df Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Fri, 24 Jan 2014 16:53:17 -0800
Subject: Replaced LSLError() calls with calls to Error()
---
.../Shared/Api/Implementation/LSL_Api.cs | 25 +++++++++-------------
1 file changed, 10 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 33dd77f..02b4007 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -890,7 +890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (channelID == 0)
{
- LSLError("Cannot use llRegionSay() on channel 0");
+ Error("llRegionSay", "Cannot use on channel 0");
return;
}
@@ -2884,7 +2884,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_DEBIT) == 0)
{
- LSLError("No permissions to give money");
+ Error("llGiveMoney", "No permissions to give money");
return;
}
@@ -2892,7 +2892,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(destination, out toID))
{
- LSLError("Bad key in llGiveMoney");
+ Error("llGiveMoney", "Bad key in llGiveMoney");
return;
}
@@ -4391,7 +4391,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID av = new UUID();
if (!UUID.TryParse(agent,out av))
{
- LSLError("First parameter to llTextBox needs to be a key");
+ Error("llTextBox", "First parameter must be a key");
return;
}
@@ -6811,17 +6811,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID av = new UUID();
if (!UUID.TryParse(avatar,out av))
{
- LSLError("First parameter to llDialog needs to be a key");
+ Error("llDialog", "First parameter must be a key");
return;
}
if (buttons.Length < 1)
{
- LSLError("No less than 1 button can be shown");
+ Error("llDialog", "At least 1 button must be shown");
return;
}
if (buttons.Length > 12)
{
- LSLError("No more than 12 buttons can be shown");
+ Error("llDialog", "No more than 12 buttons can be shown");
return;
}
string[] buts = new string[buttons.Length];
@@ -6829,12 +6829,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (buttons.Data[i].ToString() == String.Empty)
{
- LSLError("button label cannot be blank");
+ Error("llDialog", "Button label cannot be blank");
return;
}
if (buttons.Data[i].ToString().Length > 24)
{
- LSLError("button label cannot be longer than 24 characters");
+ Error("llDialog", "Button label cannot be longer than 24 characters");
return;
}
buts[i] = buttons.Data[i].ToString();
@@ -10302,7 +10302,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (quick_pay_buttons.Data.Length < 4)
{
- LSLError("List must have at least 4 elements");
+ Error("llSetPayPrice", "List must have at least 4 elements");
return;
}
m_host.ParentGroup.RootPart.PayPrice[0]=price;
@@ -11292,11 +11292,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Error(command, text);
}
- internal void LSLError(string msg)
- {
- throw new ScriptException("LSL Runtime Error: " + msg);
- }
-
public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);
protected void WithNotecard(UUID assetID, AssetRequestCallback cb)
{
--
cgit v1.1
From d405254971b2e33dc9a469701689d91af5693e75 Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Fri, 24 Jan 2014 17:33:12 -0800
Subject: Replaced llSay()ing LSL errors with calls Error()
---
.../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 02b4007..24b473d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2955,13 +2955,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (item == null)
{
- llSay(0, "Could not find object " + inventory);
+ Error("llRezAtRoot", "Could not find object " + inventory);
return;
}
if (item.InvType != (int)InventoryType.Object)
{
- llSay(0, "Unable to create requested object. Object is missing from database.");
+ Error("llRezAtRoot", "Unable to create requested object. Object is missing from database.");
return;
}
@@ -4003,7 +4003,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(destination, out destId))
{
- llSay(0, "Could not parse key " + destination);
+ Error("llGiveInventory", "Could not parse key " + destination);
return;
}
@@ -4011,8 +4011,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (item == null)
{
- llSay(0, String.Format("Could not find object '{0}'", inventory));
- throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
+ Error("llGiveInventory", String.Format("Could not find object '{0}'", inventory));
}
UUID objId = item.ItemID;
@@ -4036,7 +4035,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (account == null)
{
- llSay(0, "Can't find destination "+destId.ToString());
+ Error("llGiveInventory", "Can't find destination " + destId.ToString());
return;
}
}
@@ -6876,7 +6875,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(target, out destId))
{
- llSay(0, "Could not parse key " + target);
+ Error("llRemoteLoadScriptPin", "Could not parse key " + target);
return;
}
@@ -6892,7 +6891,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// make sure the object is a script
if (item == null || item.Type != 10)
{
- llSay(0, "Could not find script " + name);
+ Error("llRemoteLoadScriptPin", "Could not find script " + name);
return;
}
@@ -9718,7 +9717,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (item == null)
{
- llSay(0, "No item name '" + item + "'");
+ Error("llGetInventoryCreator", "Cannot find item '" + item + "'");
return String.Empty;
}
--
cgit v1.1
From 3d62f4369d800f854d8306f1ebf4ce5d3de71818 Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Sat, 25 Jan 2014 12:00:11 -0800
Subject: Replaced throwing exceptions with calls to Error()
---
.../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 24b473d..ae9f827 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7972,9 +7972,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string encodedData = Convert.ToBase64String(encData_byte);
return encodedData;
}
- catch (Exception e)
+ catch
{
- throw new Exception("Error in base64Encode" + e.Message);
+ Error("llBase64ToString", "Error encoding string");
+ return String.Empty;
}
}
@@ -7985,9 +7986,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
return Util.Base64ToString(str);
}
- catch (Exception e)
+ catch
{
- throw new Exception("Error in base64Decode" + e.Message);
+ Error("llBase64ToString", "Error decoding string");
+ return String.Empty;
}
}
@@ -10678,7 +10680,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!ok || flag < 0 ||
flag > (int)HttpRequestConstants.HTTP_PRAGMA_NO_CACHE)
{
- throw new ScriptException("Parameter " + i.ToString() + " is an invalid flag");
+ Error("llHTTPRequest", "Parameter " + i.ToString() + " is an invalid flag");
}
param.Add(parameters.Data[i].ToString()); //Add parameter flag
@@ -10702,12 +10704,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
//There must be at least one name/value pair for custom header
if (count == 1)
- throw new ScriptException("Missing name/value for custom header at parameter " + i.ToString());
+ Error("llHTTPRequest", "Missing name/value for custom header at parameter " + i.ToString());
break;
}
if (HttpStandardHeaders.Contains(parameters.Data[i].ToString(), StringComparer.OrdinalIgnoreCase))
- throw new ScriptException("Name is invalid as a custom header at parameter " + i.ToString());
+ Error("llHTTPRequest", "Name is invalid as a custom header at parameter " + i.ToString());
param.Add(parameters.Data[i].ToString());
param.Add(parameters.Data[i+1].ToString());
--
cgit v1.1
From 1380b37d71d50bb2e701f3e0a70ab0f1e2aa3407 Mon Sep 17 00:00:00 2001
From: David Rowe
Date: Sat, 25 Jan 2014 12:44:39 -0800
Subject: Made error messages more consistent
---
.../Shared/Api/Implementation/LSL_Api.cs | 30 +++++++++++-----------
1 file changed, 15 insertions(+), 15 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ae9f827..6991831 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -261,7 +261,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((item = GetScriptByName(name)) != UUID.Zero)
m_ScriptEngine.ResetScript(item);
else
- Error("llResetOtherScript", "Script " + name + " not found");
+ Error("llResetOtherScript", "Can't find script '" + name + "'");
}
public LSL_Integer llGetScriptState(string name)
@@ -275,7 +275,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return m_ScriptEngine.GetScriptState(item) ?1:0;
}
- Error("llGetScriptState", "Script " + name + " not found");
+ Error("llGetScriptState", "Can't find script '" + name + "'");
// If we didn't find it, then it's safe to
// assume it is not running.
@@ -298,7 +298,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else
{
- Error("llSetScriptState", "Script " + name + " not found");
+ Error("llSetScriptState", "Can't find script '" + name + "'");
}
}
@@ -2955,13 +2955,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (item == null)
{
- Error("llRezAtRoot", "Could not find object " + inventory);
+ Error("llRezAtRoot", "Can't find object '" + inventory + "'");
return;
}
if (item.InvType != (int)InventoryType.Object)
{
- Error("llRezAtRoot", "Unable to create requested object. Object is missing from database.");
+ Error("llRezAtRoot", "Can't create requested object; object is missing from database");
return;
}
@@ -4003,7 +4003,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(destination, out destId))
{
- Error("llGiveInventory", "Could not parse key " + destination);
+ Error("llGiveInventory", "Can't parse destination key '" + destination + "'");
return;
}
@@ -4011,7 +4011,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (item == null)
{
- Error("llGiveInventory", String.Format("Could not find object '{0}'", inventory));
+ Error("llGiveInventory", "Can't find inventory object '" + inventory + "'");
}
UUID objId = item.ItemID;
@@ -4035,7 +4035,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (account == null)
{
- Error("llGiveInventory", "Can't find destination " + destId.ToString());
+ Error("llGiveInventory", "Can't find destination '" + destId.ToString() + "'");
return;
}
}
@@ -6875,7 +6875,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(target, out destId))
{
- Error("llRemoteLoadScriptPin", "Could not parse key " + target);
+ Error("llRemoteLoadScriptPin", "Can't parse key '" + target + "'");
return;
}
@@ -6891,7 +6891,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// make sure the object is a script
if (item == null || item.Type != 10)
{
- Error("llRemoteLoadScriptPin", "Could not find script " + name);
+ Error("llRemoteLoadScriptPin", "Can't find script '" + name + "'");
return;
}
@@ -9719,7 +9719,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (item == null)
{
- Error("llGetInventoryCreator", "Cannot find item '" + item + "'");
+ Error("llGetInventoryCreator", "Can't find item '" + item + "'");
return String.Empty;
}
@@ -11322,7 +11322,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (assetID == UUID.Zero)
{
// => complain loudly, as specified by the LSL docs
- Error("llGetNumberOfNotecardLines", "Notecard '" + name + "' could not be found");
+ Error("llGetNumberOfNotecardLines", "Can't find notecard '" + name + "'");
return UUID.Zero.ToString();
}
@@ -11344,7 +11344,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (a == null || a.Type != 7)
{
- Error("llGetNumberOfNotecardLines", "Notecard '" + name + "' could not be found");
+ Error("llGetNumberOfNotecardLines", "Can't find notecard '" + name + "'");
return;
}
@@ -11375,7 +11375,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (assetID == UUID.Zero)
{
// => complain loudly, as specified by the LSL docs
- Error("llGetNotecardLine", "Notecard '" + name + "' could not be found");
+ Error("llGetNotecardLine", "Can't find notecard '" + name + "'");
return UUID.Zero.ToString();
}
@@ -11398,7 +11398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (a == null || a.Type != 7)
{
- Error("llGetNotecardLine", "Notecard '" + name + "' could not be found");
+ Error("llGetNotecardLine", "Can't find notecard '" + name + "'");
return;
}
--
cgit v1.1
From b8e22f02e79e84d29e65a46751d68235f93aa8e8 Mon Sep 17 00:00:00 2001
From: Oren Hurvitz
Date: Thu, 19 Dec 2013 14:08:46 +0200
Subject: Make sure Web streams are disposed after use
---
.../Avatar/UserProfiles/UserProfileModule.cs | 77 ++++++++++------------
.../Scripting/HttpRequest/ScriptsHttpRequests.cs | 7 +-
.../CoreModules/World/WorldMap/WorldMapModule.cs | 2 +-
.../RegionReadyModule/RegionReadyModule.cs | 2 +-
4 files changed, 40 insertions(+), 48 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index b21082f..9ae7452 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -1290,9 +1290,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
webRequest.ContentType = "application/json-rpc";
webRequest.Method = "POST";
- Stream dataStream = webRequest.GetRequestStream();
- dataStream.Write(content, 0, content.Length);
- dataStream.Close();
+ using (Stream dataStream = webRequest.GetRequestStream())
+ dataStream.Write(content, 0, content.Length);
WebResponse webResponse = null;
try
@@ -1306,26 +1305,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
return false;
}
- Stream rstream = webResponse.GetResponseStream();
-
- OSDMap mret = new OSDMap();
- try
- {
- mret = (OSDMap)OSDParser.DeserializeJson(rstream);
- }
- catch (Exception e)
+ using (webResponse)
+ using (Stream rstream = webResponse.GetResponseStream())
{
- m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message);
- return false;
- }
+ OSDMap mret = (OSDMap)OSDParser.DeserializeJson(rstream);
+ if (mret.ContainsKey("error"))
+ return false;
- if (mret.ContainsKey("error"))
- return false;
-
- // get params...
- OSD.DeserializeMembers(ref parameters, (OSDMap) mret["result"]);
- return true;
+ // get params...
+ OSD.DeserializeMembers(ref parameters, (OSDMap)mret["result"]);
+ return true;
+ }
}
///
@@ -1366,9 +1357,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
webRequest.ContentType = "application/json-rpc";
webRequest.Method = "POST";
- Stream dataStream = webRequest.GetRequestStream();
- dataStream.Write(content, 0, content.Length);
- dataStream.Close();
+ using (Stream dataStream = webRequest.GetRequestStream())
+ dataStream.Write(content, 0, content.Length);
WebResponse webResponse = null;
try
@@ -1382,29 +1372,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
return false;
}
- Stream rstream = webResponse.GetResponseStream();
-
- OSDMap response = new OSDMap();
- try
- {
- response = (OSDMap)OSDParser.DeserializeJson(rstream);
- }
- catch (Exception e)
+ using (webResponse)
+ using (Stream rstream = webResponse.GetResponseStream())
{
- m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message);
- return false;
- }
+ OSDMap response = new OSDMap();
+ try
+ {
+ response = (OSDMap)OSDParser.DeserializeJson(rstream);
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[PROFILES]: JsonRpcRequest Error {0} - remote user with legacy profiles?", e.Message);
+ return false;
+ }
- if(response.ContainsKey("error"))
- {
- data = response["error"];
- return false;
- }
+ if (response.ContainsKey("error"))
+ {
+ data = response["error"];
+ return false;
+ }
- data = response;
+ data = response;
- return true;
+ return true;
+ }
}
+
#endregion Web Util
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index c3a8afd..a7237ea 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -488,9 +488,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
byte[] data = Util.UTF8.GetBytes(OutboundBody);
Request.ContentLength = data.Length;
- Stream bstream = Request.GetRequestStream();
- bstream.Write(data, 0, data.Length);
- bstream.Close();
+ using (Stream bstream = Request.GetRequestStream())
+ bstream.Write(data, 0, data.Length);
}
try
@@ -584,4 +583,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
Request.Abort();
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index cf2ef29..03e044b 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -915,7 +915,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
finally
{
if (os != null)
- os.Close();
+ os.Dispose();
}
string response_mapItems_reply = null;
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index eb386fe..e10b9ad 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -301,7 +301,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
finally
{
if (os != null)
- os.Close();
+ os.Dispose();
}
}
}
--
cgit v1.1