Catch cannot_perform_query_exc_t exceptions in val.cc (cherry-pick).