eror handling in javascript