throws an error on query errors