Fixes #2. Add error reporting for query failures.