Guarantee a queryId on error.  The msg argument doesn't always have it.