diff --git a/src/xsprintf/qsprintf.php b/src/xsprintf/qsprintf.php
--- a/src/xsprintf/qsprintf.php
+++ b/src/xsprintf/qsprintf.php
@@ -491,6 +491,7 @@
     case 'R':
       if (!($value instanceof AphrontDatabaseTableRefInterface)) {
         throw new AphrontParameterQueryException(
+          $query,
           pht(
             'Parameter to "%s" conversion in "qsprintf(...)" is not an '.
             'instance of AphrontDatabaseTableRefInterface.',
@@ -501,6 +502,7 @@
     case 'P':
       if (!($value instanceof PhutilOpaqueEnvelope)) {
         throw new AphrontParameterQueryException(
+          $query,
           pht(
             'Parameter to "%s" conversion in "qsprintf(...)" is not an '.
             'instance of PhutilOpaqueEnvelope.',