15.2. Using the Error Class

The ASP.NET AJAX Script Library includes several useful classes with respect to debugging and testing, including the Error and Sys.Debug classes. The Error class extends the native JavaScript Error object and allows more specific error objects and messages to be created for a given error. It is used extensively throughout the ASP.NET AJAX Library debug scripts to test that the correct number of parameters are passed to functions, passed parameter types match up with the expected types, types aren't undefined, functions are fully implemented, and much more. The Error class is used sparingly in the release version of the ASP.NET AJAX Library scripts so that file sizes are minimized as much as possible.

The Error class has several different functions that can be used to create specific types of errors. The majority of the functions that can be called to create error objects relate specifically to function parameters, but others exist that are used by classes such as the PageRequestManager class. All of the Error class's available functions are shown in the following table.

Function NameDescription
argument(paramName, message)Used to create a Sys.ArgumentException object with the name of the function parameter that caused the exception, as well as the specified error message.
argumentNull(paramName, message)Used to create a Sys.ArgumentNullExeption object with the name of the function parameter that caused the exception, as well as the specified error message. ...

Get Professional ASP.NET 3.5 AJAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.