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