f5bc6b413957f25f24799f15e836757e4f82a668
chmalee
  Tue Aug 22 13:27:51 2023 -0700
Make warnings show up in search results, refs #31965

diff --git src/hg/cgilib/cartJson.c src/hg/cgilib/cartJson.c
index 36c8adf..08a721b 100644
--- src/hg/cgilib/cartJson.c
+++ src/hg/cgilib/cartJson.c
@@ -825,31 +825,37 @@
     return -1;
 if (!aIsChange && bIsChange)
     return 1;
 return strcmp(cmdA->name, cmdB->name);
 }
 
 // Accumulate warnings so they can be JSON-ified:
 static struct dyString *dyWarn = NULL;
 
 static void cartJsonVaWarn(char *format, va_list args)
 /* Save warnings for later. */
 {
 dyStringVaPrintf(dyWarn, format, args);
 }
 
-static void cartJsonPrintWarnings(struct jsonWrite *jw)
+boolean cartJsonIsNoWarns()
+/* Return TRUE if there are no warnings present */
+{
+return dyWarn && dyStringLen(dyWarn) == 0;
+}
+
+void cartJsonPrintWarnings(struct jsonWrite *jw)
 /* If there are warnings, write them out as JSON: */
 {
 if (dyWarn && dyStringLen(dyWarn) > 0)
     jsonWriteString(jw, "warning", dyWarn->string);
 }
 
 static void cartJsonAbort()
 /* Print whatever warnings we have accumulated and exit. */
 {
 if (dyWarn)
     puts(dyWarn->string);
 exit(0);
 }
 
 void cartJsonPushErrHandlers()
@@ -894,23 +900,24 @@
         struct slPair *commandList = NULL, *cmd;
         struct hashCookie cookie = hashFirst(commandHash);
         struct hashEl *hel;
         while ((hel = hashNext(&cookie)) != NULL)
             slAddHead(&commandList, slPairNew(hel->name, hel->val));
         slSort(&commandList, commandCmp);
         for (cmd = commandList;  cmd != NULL;  cmd = cmd->next)
             doOneCommand(cj, cmd->name, (struct jsonElement *)cmd->val);
         }
     errCatchEnd(errCatch);
     if (errCatch->gotError)
         {
         jsonWritePopToLevel(cj->jw, 1);
         jsonWriteString(cj->jw, "error", errCatch->message->string);
         }
+    errCatchReWarn(errCatch);
     errCatchFree(&errCatch);
     }
 
 cartJsonPrintWarnings(cj->jw);
 jsonWriteObjectEnd(cj->jw);
 puts(cj->jw->dy->string);
 cartJsonPopErrHandlers();
 }