Error.create Function

Creates an Error object that can contain additional error information.

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

Arguments

  • message
    (Optional)An error message string.

  • errorInfo
    (Optional) An instance of a JavaScript object that contains extended information about the error. The object must have a name field that contains a string that identifies the error. The object can also contain fields to fully describe the error.

Return Value

An Error object.

Remarks

Use the create function to create an Error object that can contain additional error information. The message argument enables you to attach information to the error that can be displayed in an application when the error occurs, or to provide details for tracking errors. The errorInfo argument enables you to add error information as fields to the Error object created by the function. This enables you to specify custom error information that more fully describes the error. The JavaScript object that you supply must have a field named name that contains a string that identifies the error. You can provide additional fields of any type and name in the errorInfo object, which is useful for customized exception handling.

Example

The following example shows how to create a new Error object by using the create function. Three errors are created. The first error is an Sys.ArgumentTypeException exception. The second error provides a message string that is passed in the message argument. The third error provides an error message string and an object that is passed in the errorInfo argument. The errorInfo object provides the required name field that identifies the error and an additional field that describes the error.

See Also

Concepts

Debugging and Tracing AJAX Applications Overview

Reference

Error Type Extensions

Other Resources

Language Reference