Adding try catch block to query method.

Avoid showing exception message on page.