Query and stack on errors

Store stack trace along with query in closure and add to errors for easier debugging