Narrows down exception handling to InvalidQueryError and OperationError