Rhino.ScriptRuntime.NewCatchScope C# (CSharp) Method

NewCatchScope() public static method

public static NewCatchScope ( Exception t, Scriptable lastCatchScope, string exceptionName, Context cx, Scriptable scope ) : Scriptable
t System.Exception
lastCatchScope Scriptable
exceptionName string
cx Context
scope Scriptable
return Scriptable
		public static Scriptable NewCatchScope(Exception t, Scriptable lastCatchScope, string exceptionName, Context cx, Scriptable scope)
		{
			object obj;
			bool cacheObj;
			if (t is JavaScriptException)
			{
				cacheObj = false;
				obj = ((JavaScriptException)t).GetValue();
			}
			else
			{
				cacheObj = true;
				// Create wrapper object unless it was associated with
				// the previous scope object
				if (lastCatchScope != null)
				{
					NativeObject last = (NativeObject)lastCatchScope;
					obj = last.GetAssociatedValue(t);
					if (obj == null)
					{
						Kit.CodeBug();
					}
				}
				else
				{
					obj = WrapException(t, scope, cx);
				}
			}
			NativeObject catchScopeObject = new NativeObject();
			// See ECMA 12.4
			catchScopeObject.DefineProperty(exceptionName, obj, ScriptableObject.PERMANENT);
			if (IsVisible(cx, t))
			{
				// Add special Rhino object __exception__ defined in the catch
				// scope that can be used to retrieve the Java exception associated
				// with the JavaScript exception (to get stack trace info, etc.)
				catchScopeObject.DefineProperty("__exception__", Context.JavaToJS(t, scope), ScriptableObject.PERMANENT | ScriptableObject.DONTENUM);
			}
			if (cacheObj)
			{
				catchScopeObject.AssociateValue(t, obj);
			}
			return catchScopeObject;
		}
ScriptRuntime