c4886d0cc011b2976205cb5bd297af416292a897
chmalee
  Fri Jan 20 10:39:23 2023 -0800
Add errCatch around primary hgLiftover procedure so we can still display documentation when there is a user error, refs #3703

diff --git src/hg/hgLiftOver/hgLiftOver.c src/hg/hgLiftOver/hgLiftOver.c
index ae96cf0..9c70358 100644
--- src/hg/hgLiftOver/hgLiftOver.c
+++ src/hg/hgLiftOver/hgLiftOver.c
@@ -7,30 +7,31 @@
 #include "hCommon.h"
 #include "jksql.h"
 #include "portable.h"
 #include "linefile.h"
 #include "dnautil.h"
 #include "fa.h"
 #include "cheapcgi.h"
 #include "htmshell.h"
 #include "hdb.h"
 #include "hui.h"
 #include "cart.h"
 #include "web.h"
 #include "hash.h"
 #include "liftOver.h"
 #include "liftOverChain.h"
+#include "errCatch.h"
 
 
 /* CGI Variables */
 #define HGLFT_USERDATA_VAR "hglft_userData"     /* typed/pasted in data */
 #define HGLFT_DATAFILE_VAR "hglft_dataFile"     /* file of data to convert */
 #define HGLFT_FROMORG_VAR "hglft_fromOrg"         /* FROM organism */
 #define HGLFT_FROMDB_VAR "hglft_fromDb"         /* FROM assembly */
 #define HGLFT_TOORG_VAR   "hglft_toOrg"           /* TO organism */
 #define HGLFT_TODB_VAR   "hglft_toDb"           /* TO assembly */
 #define HGLFT_ERRORHELP_VAR "hglft_errorHelp"      /* Print explanatory text */
 #define HGLFT_REFRESHONLY_VAR "hglft_doRefreshOnly"      /* Just refresh drop-down lists */
 #define HGLFT_LAST_CHAIN "hglft_lastChain"
 
 /* liftOver options: */
 #define HGLFT_MINMATCH "hglft_minMatch"          
@@ -468,30 +469,33 @@
 
 minSizeQ = cartCgiUsualInt(cart, HGLFT_MINSIZEQ, choice->minSizeQ);
 minChainT = cartCgiUsualInt(cart, HGLFT_MINCHAINT, choice->minChainT);
 minBlocks = cartCgiUsualDouble(cart, HGLFT_MINBLOCKS, choice->minBlocks);
 minMatch = cartCgiUsualDouble(cart, HGLFT_MINMATCH, choice->minMatch);
 fudgeThick = cartCgiUsualBoolean(cart, HGLFT_FUDGETHICK, (choice->fudgeThick[0]=='Y') ? TRUE : FALSE);
 multiple = cartCgiUsualBoolean(cart, HGLFT_MULTIPLE, (choice->multiple[0]=='Y') ? TRUE : FALSE);
 refreshOnly = cartCgiUsualInt(cart, HGLFT_REFRESHONLY_VAR, 0);
 lastChain = cartCgiUsualString(cart, HGLFT_LAST_CHAIN, NULL);
 if (lastChain && thisChain && sameString(lastChain, thisChain))
     keepSettings = TRUE;
 
 webMain(choice, multiple, keepSettings, minSizeQ, minChainT, minBlocks, minMatch, fudgeThick);
 liftOverChainFreeList(&chainList);
 
+struct errCatch *errCatch = errCatchNew();
+if (errCatchStart(errCatch))
+    {
     if (!refreshOnly && userData != NULL && userData[0] != '\0')
         {
         struct hash *chainHash = newHash(0);
         char *chainFile;
         struct tempName oldTn, mappedTn, unmappedTn;
         FILE *old, *mapped, *unmapped;
         char *line;
         int lineSize;
         char *fromDb, *toDb;
         int ct = -1, errCt = 0;
         enum liftOverFileType lft;
         /* read in user data and save to file */
         makeTempName(&oldTn, HGLFT, ".user");
         old = mustOpen(oldTn.forCgi, "w");
         fputs(userData, old);
@@ -555,30 +559,35 @@
             while (lineFileNext(errFile, &line, &lineSize))
                 puts(line);
             lineFileClose(&errFile);
             puts("</PRE></BLOCKQUOTE>\n");
             }
         if ((multiple) && (lft == positions))
         {
         puts("<BLOCKQUOTE><PRE>\n");
         puts("Note: &quot;multiple&quot; option is not supported for position format.");
         puts("</PRE></BLOCKQUOTE>\n");
         }
         webParamsUsed(minMatch, multiple, minSizeQ, minChainT, minBlocks, fudgeThick);
 
         carefulClose(&unmapped);
         }
+    }
+errCatchEnd(errCatch);
+if (errCatch->gotError || errCatch->gotWarning)
+    warn("%s", errCatch->message->string);
+errCatchFree(&errCatch);
 webDownloads();
 cartWebEnd();
 }
 
 /* Null terminated list of CGI Variables we don't want to save
  * permanently. */
 char *excludeVars[] = {"Submit", "submit", "SubmitFile",
                         HGLFT_USERDATA_VAR,
                         HGLFT_DATAFILE_VAR,
                         HGLFT_ERRORHELP_VAR,
                         NULL};
 
 int main(int argc, char *argv[])
 /* Process command line. */
 {