Export (0) Print
Expand All

Error Type Extensions

.NET Framework 3.5

Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release).

Namespace: None. This type extension is global and not part of a namespace.

Inherits: None

var err = Error.create(message, errorInfo);

Name

Description

Error.argument Function

Creates an Error object that represents the Sys.ArgumentException exception.

Error.argumentNull Function

Creates an Error object that represents the Sys.ArgumentNullException exception.

Error.argumentOutOfRange Function

Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception.

Error.argumentType Function

Creates an Error object that represents the Sys.ArgumentTypeException exception.

Error.argumentUndefined Function

Creates an Error object that represents the Sys.ArgumentUndefinedException exception.

Error.create Function

Creates an Error object that has optional additional error information.

Error.format Function

Creates an Error object that represents the Sys.FormatException exception.

Error.invalidOperation Function

Creates an Error object that represents the Sys.InvalidOperationException exception.

Error.message Field

Represents the description of the error.

Error.name Field

Represents the name that identifies the error.

Error.notImplemented Function

Creates an Error object that represents the Sys.NotImplementedException exception.

Error.parameterCount Function

Creates an Error object that represents the Sys.ParameterCountException exception.

Error.popStackFrame Function

Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types.

Error extensions are part of the Microsoft AJAX Library. They add functionality to the built-in JavaScript Error object.

Error Types

The Error type extensions generate an Error type with additional fields that represent the exception details. All Error type extensions add at least a name field to identify the exception. You can test the exception's name field to determine what action to take.

The following example shows how to test the Error,name property for the Sys.ArgumentNullException exception.

try{ } 
catch (e) {
    if (e.name === "Sys.ArgumentNullException"){
        // Code here ot handle exception.
    }
}

For more information about the JavaScript object that this type extends, see Error Object in the Language Reference.

Optimizing Client-Script Error Handling for Debug and Release Modes

The ASP.NET AJAX Error object extensions provide additional client-script error handling functionality.

ASP.NET provides debug and release application-compilation modes for working with AJAX client script. This enables you to throw exceptions in debug scripts that are helpful to the debugging process, while minimizing the size of release code to emphasize performance. Debug mode provides additional error-handling features, such as type checking and argument checking, and provides more detailed error messages than release mode does.

For more information, see How to: Enable Debugging for ASP.NET Applications and Debugging and Tracing AJAX Applications Overview.

The following example shows how to create a new Error instance by invoking the create method of the ASP.NET AJAX Error object.

Community Additions

ADD
Show:
© 2014 Microsoft