Patch by Tomasz Kuchta adding more detailed information on query failures.