Allow NewQueryEngine to return an error

Some errors only bubble up from pretty deep. A "SELECT COUNT(*)" was
ending up as a panic, when instead it should have been returned as a
query error to the user.

This adds plumbing for returning an error from NewQueryEngine.