When scripts generate expected exceptions (e.g. due to checked bad parameter) throw ScriptException instead of just a plain old exception.

This is to make it easier to distinguish these exceptions from unexpected OpenSimulator problems internally and in regression tests.
No functional changes.
0.7.4-extended
Justin Clark-Casey (justincc) 2012-10-25 02:52:20 +01:00
parent 95e35fe84a
commit 28ced402d8
5 changed files with 52 additions and 9 deletions

View File

@ -38,7 +38,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
public partial class Scene public partial class Scene
{ {
protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName,
UUID fromID, UUID targetID, bool fromAgent, bool broadcast) UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
{ {
@ -66,6 +65,10 @@ namespace OpenSim.Region.Framework.Scenes
args.From = fromName; args.From = fromName;
args.TargetUUID = targetID; args.TargetUUID = targetID;
// m_log.DebugFormat(
// "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}",
// args.Message.Replace("\n", "\\n"), args.Channel, args.Type, fromName, broadcast);
if (broadcast) if (broadcast)
EventManager.TriggerOnChatBroadcast(this, args); EventManager.TriggerOnChatBroadcast(this, args);
else else

View File

@ -10589,12 +10589,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal void Deprecated(string command) internal void Deprecated(string command)
{ {
throw new Exception("Command deprecated: " + command); throw new ScriptException("Command deprecated: " + command);
} }
internal void LSLError(string msg) internal void LSLError(string msg)
{ {
throw new Exception("LSL Runtime Error: " + msg); throw new ScriptException("LSL Runtime Error: " + msg);
} }
public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); public delegate void AssetRequestCallback(UUID assetID, AssetBase asset);

View File

@ -95,13 +95,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal void MODError(string msg) internal void MODError(string msg)
{ {
throw new Exception("MOD Runtime Error: " + msg); throw new ScriptException("MOD Runtime Error: " + msg);
} }
// /// <summary>
//Dumps an error message on the debug console. /// Dumps an error message on the debug console.
// /// </summary>
/// <param name='message'></param>
internal void MODShoutError(string message) internal void MODShoutError(string message)
{ {
if (message.Length > 1023) if (message.Length > 1023)

View File

@ -206,7 +206,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal void OSSLError(string msg) internal void OSSLError(string msg)
{ {
throw new Exception("OSSL Runtime Error: " + msg); throw new ScriptException("OSSL Runtime Error: " + msg);
} }
/// <summary> /// <summary>

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace OpenSim.Region.ScriptEngine.Shared
{
public class ScriptException : Exception
{
public ScriptException() : base() {}
public ScriptException(string message) : base(message) {}
public ScriptException(string message, Exception innerException) : base(message, innerException) {}
}
}