521b2b4eef45c42118df575b16d27662e5407a65 kate Thu May 21 10:26:22 2015 -0700 Clean up error messages so count is correct. refs #10015 diff --git src/hg/lib/trackHubCheck.c src/hg/lib/trackHubCheck.c index 963f1c4..67c6746 100644 --- src/hg/lib/trackHubCheck.c +++ src/hg/lib/trackHubCheck.c @@ -110,36 +110,36 @@ if (options->extra && hashLookup(options->extra, setting)) return 0; struct errCatch *errCatch = errCatchNew(); if (errCatchStart(errCatch)) { /* check setting is supported in this version */ struct trackHubSetting *hubSetting = hashFindVal(options->settings, setting); if (hubSetting == NULL) { struct dyString *ds = dyStringNew(0); dyStringPrintf(ds, "Setting '%s' is unknown/unsupported", setting); char *suggest = suggestSetting(setting, options); if (suggest != NULL) dyStringPrintf(ds, " (did you mean '%s' ?) ", suggest); - errAbort("%s\n", dyStringCannibalize(&ds)); + errAbort("%s", dyStringCannibalize(&ds)); } // check level if (options->strict && differentString(hubSetting->level, "core")) - errAbort( "Setting '%s' is level '%s'\n", setting, hubSetting->level); + errAbort( "Setting '%s' is level '%s'", setting, hubSetting->level); } errCatchEnd(errCatch); if (errCatch->gotError) { dyStringPrintf(errors, "%s", errCatch->message->string); retVal = 1; } errCatchFree(&errCatch); return retVal; } static void hubCheckTrackFile(struct trackHub *hub, struct trackHubGenome *genome, struct trackDb *tdb) /* Check remote file exists and is of correct type. Wrap this in error catcher */ { @@ -153,58 +153,58 @@ { /* Just open and close to verify file exists and is correct type. */ struct bbiFile *bbi = bigWigFileOpen(bigDataUrl); bbiFileClose(&bbi); } else if (startsWithWord("bigBed", type) || startsWithWord("bigGenePred", type)) { /* Just open and close to verify file exists and is correct type. */ struct bbiFile *bbi = bigBedFileOpen(bigDataUrl); char *typeString = cloneString(type); nextWord(&typeString); if (typeString != NULL) { unsigned numFields = sqlUnsigned(nextWord(&typeString)); if (numFields > bbi->fieldCount) - errAbort("fewer fields in bigBed (%d) than in type statement (%d) for track %s with bigDataUrl %s\n", bbi->fieldCount, numFields, trackHubSkipHubName(tdb->track), bigDataUrl); + errAbort("fewer fields in bigBed (%d) than in type statement (%d) for track %s with bigDataUrl %s", bbi->fieldCount, numFields, trackHubSkipHubName(tdb->track), bigDataUrl); } bbiFileClose(&bbi); } else if (startsWithWord("vcfTabix", type)) { /* Just open and close to verify file exists and is correct type. */ struct vcfFile *vcf = vcfTabixFileMayOpen(bigDataUrl, NULL, 0, 0, 1, 1); if (vcf == NULL) // Warnings already indicated whether the tabix file is missing etc. errAbort("Couldn't open %s and/or its tabix index (.tbi) file. " "See http://genome.ucsc.edu/goldenPath/help/vcf.html", bigDataUrl); vcfFileFree(&vcf); } else if (startsWithWord("bam", type)) { bamFileAndIndexMustExist(bigDataUrl); } #ifdef USE_HAL else if (startsWithWord("halSnake", type)) { char *errString; int handle = halOpenLOD(bigDataUrl, &errString); if (handle < 0) - errAbort("HAL open error: %s\n", errString); + errAbort("HAL open error: %s", errString); if (halClose(handle, &errString) < 0) - errAbort("HAL close error: %s\n", errString); + errAbort("HAL close error: %s", errString); } #endif else errAbort("unrecognized type %s in genome %s track %s", type, genome->name, tdb->track); freez(&bigDataUrl); } } static int hubCheckTrack(struct trackHub *hub, struct trackHubGenome *genome, struct trackDb *tdb, struct trackHubCheckOptions *options, struct dyString *errors) /* Check track settings and optionally, files */ { int retVal = 0; @@ -309,31 +309,31 @@ version = trackHubVersionDefault(); char *specUrl; if (startsWith("http", version)) specUrl = version; else { char buf[256]; char *specHost = "genome.ucsc.edu"; safef(buf, sizeof buf, "http://%s/goldenPath/help/trackDb/trackDbHub.%s.html", specHost, version); specUrl = buf; } verbose(2, "Validating to spec at %s\n", specUrl); struct htmlPage *page = htmlPageGet(specUrl); if (page == NULL) - errAbort("Can't open trackDb settings spec %s\n", specUrl); + errAbort("Can't open hub settings spec %s", specUrl); //TODO: apply page validator //htmlPageValidateOrAbort(page); // would like to use this, but current page doesn't validate // Would need to replace empty table (replaced by JS) with div, and assure htmlPageValidateOrAbort // is run on any page change. /* TODO: validate this is a trackDbHub spec */ /* (scan tags for tag->name="span" tag->attribute="id", attr->"value=trackDbHub_version", * might want to limit to first N tags) */ /* Retrieve specs from file url. * Settings are the first text word within any element nested in * a
having * attribute class="format". The support level ('level-*') is the class value of the * tag. * E.g.
boxedConfig on
produces: * setting=boxedConfig, class=core */ @@ -386,53 +386,53 @@ } else if (trackHubSettingLevelCmp(spec, savedSpec) > 0) { hashReplace(specHash, spec->name, spec); verbose(6, "replaced spec %s at level %s, was %s\n", spec->name, spec->level, savedSpec->level); } } } verbose(5, "Found %d
's\n", divCount); struct hashEl *el, *list = hashElListHash(specHash); int settingsCt = slCount(list); verbose(5, "Found %d settings's\n", slCount(list)); if (settingsCt == 0) - errAbort("Can't find trackDb settings support levels at %s." - " Use -v to indicate a different version number or url.\n", specUrl); + errAbort("Can't find hub setting info at %s." + " Use -version to indicate a different version number or url.", specUrl); slSort(&list, hashElCmp); struct trackHubSetting *specs = NULL; int coreCt = 0; for (el = list; el != NULL; el = el->next) { if (sameString(((struct trackHubSetting *)el->val)->level, "core")) coreCt++; slAddHead(&specs, el->val); } slReverse(&specs); verbose(3, "Found %d supported settings for this version (%d core)\n", slCount(specs), coreCt); return specs; } static int hubSettingsCheckInit(struct trackHub *hub, struct trackHubCheckOptions *options, struct dyString *errors) { int retVal = 0; -if (hub->version != NULL) +if (hub->version != NULL && options->version == NULL) options->version = hub->version; else if (options->version == NULL) options->version = trackHubVersionDefault(); if (options->strict == FALSE && hub->level != NULL) { if (sameString(hub->level, "core")) options->strict = TRUE; else if (differentString(hub->level, "all")) { dyStringPrintf(errors, "Unknown hub support level: %s (expecting 'core' or 'all'). Defaulting to 'all'.\n", hub->level); retVal = 1; } }