Changed the exception type in query builder