Sys.Debug fail Method
Displays a message in the debugger's output window and breaks into the debugger.
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 Debugging and Tracing Ajax Applications 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.
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.");
}
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.");
}