js error handling try, catch

Error Handling try catch

try / catch statement for error handling code that may occur

  • Error code block test try statement
  • catch statement to handle errors
try{
//在这里运行代码
}
catch(err){
//在这里处理错误
}

try catch error handling those beyond our control, such as the back end of nodeJs or java read I / O operations such as reading more database front-end can be used to upload pictures, using someone else's library js error, async await synchronous transfer interface where applicable
in front of the words when clearly know their code error occurs, then use try catch statement it is not appropriate, async / await now have a good handle exceptions logic of the so caution this

Guess you like

Origin www.cnblogs.com/my466879168/p/12454708.html