Return 500 error if we fail a query early in processing

cbugg: close bug-938
Some lint cleanup