Reputation: 3501
I have the following code structure:
callFunction()
if (there was an error in callFunction()){
//Execute code
}
What can I put in place of 'there was an error in callFunction()' that will tell me an error was called in that function? Is there line I should add to callFunction
itself?
Upvotes: 0
Views: 36
Reputation: 12950
try catch
is one way to do it. http://www.w3schools.com/js/js_errors.asp
For example:
function myFunction() {
try {
//some code to execute
}
catch (e) {
//throw an alert message if the try statement failed
alert(e.toString());
}
}
Upvotes: 1