Tag: ess cli inner html. com: HTTP doctype code
I believe that in actual projects, you may often see code similar to the following:
Try {// try to execute the code block} catch (ERR) {// capture the wrong code block} finally {// how the result will be executed code block}
In short, the above code is used to handle possible error messages in the code.
Try {}Indicates the code to be executed.
Catch {}For captureTry {}Error message in Code Execution
Finally {}Code that will be executed anyway
I will list an example below. Sometimes the text description is not intuitive and easy to understand. I will try to understand the relevant code and try to understand it. Maybe it will be easy to understand.
<! Doctype HTML>
Note:The preceding example shows that the show () method in the clickme () method is executed after clicking the button. Because this method is not defined, an error is returned, prompting that this method is not defined.
The following example describesCatch {}The error message is captured throughThrowHow to create a custom message
<! Doctype HTML>
Supplement:
①: Try and catch (must be used together)
②: Try and catch and throw (if you want to create a custom message, use it together)
③: Try, catch, and finally (finally is not mandatory and optional)
Two simple instances allow you to quickly understand Try-catch usage