060c9d0ae2bf7b3333d76c15ee3b114c3278f519
braney
  Sat Oct 8 14:29:09 2011 -0700
check trackDb.txt files and hub.txt files more closely in hgHubConnect so errors can be discovered ASAP.  #4679 and others.
diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c
index 9015da2..0ea81e0 100644
--- src/hg/hgHubConnect/hgHubConnect.c
+++ src/hg/hgHubConnect/hgHubConnect.c
@@ -232,31 +232,33 @@
 	    printf(
 	    "<input name=\"hubClearButton\""
 		"onClick=\"document.resetHubForm.elements['hubUrl'].value='%s';"
 		    "document.resetHubForm.submit();return true;\" "
 		    "class=\"hubField\" type=\"button\" value=\"clear error\">"
 		    , url);
 	    ourCellEnd();
 	    }
 	else
 	    errAbort("cannot get id for hub with url %s\n", url);
 
 	ourPrintCell(shortLabel);
 	if (isEmpty(errorMessage))
 	    ourPrintCell(longLabel);
 	else
-	    printf("<TD>ERROR: %s</TD>", errorMessage);
+	    printf("<TD><span class=\"hubError\">ERROR: %s </span>"
+		"<a href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug</a></TD>", 
+		errorMessage);
 
 	ourPrintCell(url);
 	}
     }
 sqlFreeResult(&sr);
 
 if (gotAnyRows)
     {
     printf("</TR></tbody></TABLE>\n");
     }
 else
     {
     printf("<div id=\"publicHubs\" class=\"hubList\"> \n");
     printf("No Public Track Hubs for this genome assembly<BR>");
     }
@@ -313,30 +315,53 @@
 
 static void doDisconnectHub(struct cart *theCart)
 {
 char *id = cartOptionalString(cart, "hubId");
 
 if (id != NULL)
     {
     char buffer[1024];
     safef(buffer, sizeof buffer, "hgHubConnect.hub.%s", id);
     cartRemove(cart, buffer);
     }
 
 cartRemove(theCart, "hubId");
 }
 
+static void checkTrackDbs(struct hubConnectStatus *hubList)
+{
+struct hubConnectStatus *hub = hubList;
+struct trackHub *trackHubList = NULL;
+
+for(; hub; hub = hub->next)
+    {
+    struct errCatch *errCatch = errCatchNew();
+    if (errCatchStart(errCatch))
+	{
+	trackHubAddTracks(hub->id, hub->hubUrl, database, &trackHubList);
+	}
+    errCatchEnd(errCatch);
+    if (errCatch->gotError)
+	{
+	hub->errorMessage = cloneString(errCatch->message->string);
+	hubUpdateStatus( errCatch->message->string, hub);
+	}
+    else
+	hubUpdateStatus(NULL, hub);
+    }
+}
+
 void doMiddle(struct cart *theCart)
 /* Write header and body of html page. */
 {
 boolean gotDisconnect = FALSE;
 
 cart = theCart;
 setUdcCacheDir();
 
 if (cartVarExists(cart, hgHubDoClear))
     {
     doClearHub(cart);
     cartWebEnd();
     return;
     }
 
@@ -375,30 +400,32 @@
    "User's Guide</A>.</P>\n"
    "<P><B>NOTE: Because Track Hubs are created and maintained by external sources,"
    " UCSC cannot be held responsible for their content.</B></P>"
    );
 printf("</div>\n");
 
 // figure out and print out genome name
 makeGenomePrint();
 
 // check to see if we have any new hubs
 hubCheckForNew(database, cart);
 
 // grab all the hubs that are listed in the cart
 struct hubConnectStatus *hubList =  hubConnectStatusListFromCartAll(cart);
 
+checkTrackDbs(hubList);
+
 // here's a little form for the add new hub button
 printf("<FORM ACTION=\"%s\" NAME=\"addHubForm\">\n",  "../cgi-bin/hgHubConnect");
 cgiMakeHiddenVar("hubUrl", "");
 cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on");
 puts("</FORM>");
 
 // this the form for the disconnect hub button
 printf("<FORM ACTION=\"%s\" NAME=\"disconnectHubForm\">\n",  "../cgi-bin/hgHubConnect");
 cgiMakeHiddenVar("hubId", "");
 cgiMakeHiddenVar(hgHubDoDisconnect, "on");
 cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on");
 puts("</FORM>");
 
 // this the form for the reset hub button
 printf("<FORM ACTION=\"%s\" NAME=\"resetHubForm\">\n",  "../cgi-bin/hgHubConnect");