Improving exception message with query.