I know that using following block, it is able to catch an Exception.
try{
// Code
}catch(err){
alert(err.message);
}
Say, I want to catch a NumberFormatException. How can I catch a specific Exception using JavaScript?
(I actually want to catch NumberFormatException, InterruptedException, ConnectException which are well defined in Java)
NumberFormatExceptionin JavaScript, norInterruptedException, norConnectException. JavaScript has as much in common with Java as a manhole has with a man. If you wish to know whether a string is a well-formed number or not, useisNaN()on the result ofparseInt()orparseFloat().