src/hg/lib/customFactory.c 1.112

1.112 2009/12/09 19:26:12 galt
Added Catch around remote resource (big*, bam) loader when it tries to open the resource
Index: src/hg/lib/customFactory.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/customFactory.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -b -B -U 4 -r1.111 -r1.112
--- src/hg/lib/customFactory.c	18 Nov 2009 00:16:26 -0000	1.111
+++ src/hg/lib/customFactory.c	9 Dec 2009 19:26:12 -0000	1.112
@@ -1475,9 +1475,22 @@
 struct hash *settings = track->tdb->settingsHash;
 char *bigDataUrl = hashFindVal(settings, "bigDataUrl");
 if (bigDataUrl == NULL)
     errAbort("Missing bigDataUrl setting from track of type=bigWig");
-track->bbiFile = bigWigFileOpen(bigDataUrl);
+
+/* protect against temporary network error */
+struct errCatch *errCatch = errCatchNew();
+if (errCatchStart(errCatch))
+    {
+    track->bbiFile = bigWigFileOpen(bigDataUrl);
+    }
+errCatchEnd(errCatch);
+if (errCatch->gotError)
+    {
+    track->networkErrMsg = cloneString(errCatch->message->string);
+    }
+errCatchFree(&errCatch);
+
 setBbiViewLimits(track);
 return track;
 }
 
@@ -1509,9 +1522,23 @@
 struct hash *settings = track->tdb->settingsHash;
 char *bigDataUrl = hashFindVal(settings, "bigDataUrl");
 if (bigDataUrl == NULL)
     errAbort("Missing bigDataUrl setting from track of type=bigBed");
-track->bbiFile = bigBedFileOpen(bigDataUrl);
+
+/* protect against temporary network error */
+struct errCatch *errCatch = errCatchNew();
+if (errCatchStart(errCatch))
+    {
+    track->bbiFile = bigBedFileOpen(bigDataUrl);
+    }
+errCatchEnd(errCatch);
+if (errCatch->gotError)
+    {
+    track->networkErrMsg = cloneString(errCatch->message->string);
+    return track;
+    }
+errCatchFree(&errCatch);
+
 setBbiViewLimits(track);
 return track;
 }
 
@@ -1545,11 +1572,28 @@
 if (bigDataUrl == NULL)
     errAbort("Missing bigDataUrl setting from track of type=bam (%s)", track->tdb->shortLabel);
 if (doExtraChecking)
     {
+    
+    /* protect against temporary network error */
+    struct errCatch *errCatch = errCatchNew();
+    if (errCatchStart(errCatch))
+	{
     if (!bamFileExists(bigDataUrl))
-	errAbort("Can't access %s's bigDataUrl %s and/or the associated index file %s.bai",
+	    {
+	    char errMsg[1024];
+            safef(errMsg, sizeof(errMsg), "Can't access %s's bigDataUrl %s and/or the associated index file %s.bai",
 		 track->tdb->shortLabel, bigDataUrl, bigDataUrl);
+	    track->networkErrMsg = cloneString(errMsg);
+	    }
+	}
+    errCatchEnd(errCatch);
+    if (errCatch->gotError)
+	{
+	track->networkErrMsg = cloneString(errCatch->message->string);
+	}
+    errCatchFree(&errCatch);
+    
     }
 return track;
 }