Handling "fail" in a script

I’m taking my first look at ECMA scripting on the server and have run some tests using the “fail” action. How do I get the client to handle the call to “fail” in a more graceful way than the default exception?

Thanks, Bob

The EcmaScriptProvider have a ScriptError event for this. In its handler you can manipulate with an instance of the ScripException object, that contains the information about the script error. For Example, you can add the following code to handle the fail action in our Scripting Sample:

private void scriptProvider_ScriptError(object sender, ScriptErrorEventArgs e)
{
    if (e.ScriptException.Type == ScriptExceptionType.Fail)
        AddToLog(string.Format("Fail occurred in the handler of {0} event. Reason: {1}", 
                                e.ScriptException.Event, e.ScriptException.Message));
}

Hope this helps.