This should also work:

```php
if (!$data) {
    throw new NoResultException(sprintf('Could not execute query %s', $query));
}
```