JavaScript anti-wrong

xiaoxiao2021-03-06  40

Function trycatchdemo (x) {

Try {

Try {

IF (x == 0) // Estimates the value of the parameter.

Throw "x equals zero"; // Throw an error.

Else

Throw "x does not equal zero"; // Throw a different error.

}

Catch (e) {// Treats "x = 0" error here.

IF (e == "x equals zero" // check if the error can be processed here.

RETURN (E "Handled Locally."); // Returns object error message.

Else // cannot handle this error here.

Throw e; // Re-thrown the error to the next one

} // Error handler.

}

Catch (e) {// Treat additional errors here.

Return (E "Handled Higher Up."); // Returns an error message.

}

}

Document.write (TrycatchDemo (0));

Document.write (TrycatchDemo (1));

转载请注明原文地址:https://www.9cbs.com/read-68135.html

New Post(0)