Error.parameterCount Function
Creates an Error object that represents the Sys.ParameterCountException exception.
var err = Error.parameterCount(message);
The following example shows how to create, throw, and catch a Sys.ParameterCountException error by using the parameterCount function.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Sample</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager runat="server" ID="ScriptManager1"> </asp:ScriptManager> <script type="text/javascript"> function throwAnError(a, b) { if (arguments.length !== arguments.callee.length) { // Throw a standard exception. var err = Error.parameterCount("Invalid number of parameters attempted."); throw err; } alert("No error occured."); } // Result: A Thrown Sys.ParameterCountException with the following message: // Error: Sys.ParameterCountException: Invalid number of parameters attempted. throwAnError(1,2,3,4); </script> </form> </body> </html>
Show: