Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.Debug fail Method

Displays a message in the debugger's output window and breaks into the debugger.

Syntax

Sys.Debug.fail(message);

Arguments

message

The message to display.

Remarks

The fail method should be used to catch developer errors. To respond to user errors and run-time error conditions such as network errors or permissions failures, throw an exception.

Debugging behavior, requirements, and the output of trace messages vary with different browsers. For more information, see ASP.NET AJAX Debugging and Tracing Overview

Example

The following example shows a function that fails if the user-defined variable n is not set to a numeric value. This is part of a larger example from the Sys.Debug class overview.

CS

function btnFail_onclick() {
    var n;
    // Insert code intended to set n to a numeric value.
    if (false) n = 3;
    // Fail if n is not numeric.
    if (isNaN(n)) Sys.Debug.fail("The value of n must be a number.");
}

VB

function btnFail_onclick() {
    var n;
    // Insert code intended to set n to a numeric value.
    if (false) n = 3;
    // Fail if n is not numeric.
    if (isNaN(n)) Sys.Debug.fail("The value of n must be a number.");
}