if statements need parenthesis.  Also, couldn't you just move this inside the try catch block and get rid of the additional variable.