Thursday, July 31, 2014

Javascript Errors exceptions and handling

-Error:

  • There might be alot of errors in your code which you cant see or know what is it maybe you'll put a double into integer variable and this is an error maybe the browser console"compiler" wont see this an error but it might cause a problem for your project
-Try statement:

  • this statements is used to check the code from errors but it wont show that error it'll just find it and throw it to another statements which called "Catch"
-Catch statement:

  • it'll handle the error from the try block and catch it and then you can print it to show your error 
  • so Try statements wont work by itself and catch statement doesn't have a value without the Try so there isnt a Try statement without a catch statement.
-Finally:

  • its an extra component which has code into it that will run after the try is clean of errors and the catch didn't get any error 
  •  we all know what the function "alert" do it shows up a message text box into your screen and it has a  text 
  • lets see this example:
why this is an error because there isn't a function called "alerttt" so this will produce an error and it'll be like this:
thats the error.
  • the catch parameter "err" is the error the the try statement could find it  so it'll pass it to the catch function by a parameter
-Related to this post:



No comments:

Post a Comment