JS in Try....catch

Source: Internet
Author: User

1, things still have to be saved, change the road to go
try {
Execute a logic
} catch (e) {
There's a problem, another logical execution.
}

2, a decent exit
try {
Normal process
} catch (e) {
Play a box and tell the user I'm sorry there was something wrong.
If it's the user's fault, tell the user what's wrong.
If the program is wrong, tell the user that I can't do it.
}______________________________________________________________________________________________________________
var NULL ; Try {  document.write (array[0catch(err) {  Document.writeln ("Error Name:" + Err.name + "");  Document.writeln ("Error message:" + err.message);} finally {  alert ("object is null");}

Program execution Process

1. array[0] The array is an empty object when the array is not created, and the program calls Array[0] produces an object is null exception
2. catch (ERR) statement captures this exception by Err.name printing the error type, Err.message prints the details of the error.
3. Finally similar to the finally Java, no exception will be executed.

We summarize the information of the six values of Error.name:

1. The use of Evalerror:eval () is inconsistent with the definition
2. Rangeerror: Value out of bounds
3. Referenceerror: Illegal or unrecognized reference value
4. SyntaxError: Syntax parsing error occurred
5. TypeError: Wrong type of operand
6. Improper use of Urierror:uri processing functions

JS in Try....catch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.