I am trying to test in browsermob if certain input field work or not. I am attempting to use a try…catch statement which I have never used before. I know that the form is:
try {
//some code
} catch (){
//some error code
};
What exactly is supposed to be put in the parenthesis after the catch statement?
When I try to use the statement it runs everything through the catch statement no matter if it is not an error. What am I doing wrong?
See the “
try...catchstatement” guide on MDN.In short, try/catch is used to handle exceptions (which are “thrown” using the
throwstatement). The syntax for try/catch is:varNameis available to the scope of thecatchblock only. It refers to the exception object which was thrown (which could be any type of object, e.g. aString, but is usually anErrorobject).