2/13/2014

Javascript Error Handling(Try, Catch)

When you want to handle errors in your code, you can use try, catch statement.
Here is the tips for the way to switch error types using error object types.

Errors Type

  • EvalError: using eval wrongly
  • RangeError: number or array range violation
  • ReferenceError: wring reference used
  • SyntaxError: worng syntax in your code
  • TypeError: varialble used with different type
  • URIError: encodeURI, decodeURI missused
Example
try{
//some code here
}catch(e){
   if( e instanceof TypeError){
          //do somethign for error
   }
}