4604bbe49ece6900be69ff88f34522738dafa36c kent Mon Nov 29 12:24:50 2021 -0800 Improving error messages. diff --git src/tabFile/tabJoin/tabJoin.c src/tabFile/tabJoin/tabJoin.c index e6e35e4..ee3f397 100644 --- src/tabFile/tabJoin/tabJoin.c +++ src/tabFile/tabJoin/tabJoin.c @@ -20,63 +20,63 @@ " -xxx=XXX\n" ); } /* Command line validation table. */ static struct optionSpec options[] = { {NULL, 0}, }; void tabJoin(char *fileName1, char *fieldName1, char *fileName2, char *fieldName2, char *outFile) /* tabJoin - Join together two tab-separated files based on a common field. */ { struct fieldedTable *table1 = fieldedTableFromTabFile(fileName1, fileName1, &fieldName1, 1); struct fieldedTable *table2 = fieldedTableFromTabFile(fileName2, fileName2, &fieldName2, 1); if (table1->rowCount != table2->rowCount) - errAbort("%s has %d rows but %s has %d. They must have same number of rows.\n", + errAbort("%s has %d rows but %s has %d. They must have same number of rows.", fileName1, table1->rowCount, fileName2, table2->rowCount); struct hash *hash1 = fieldedTableUniqueIndex(table1, fieldName1); struct hash *hash2 = fieldedTableUniqueIndex(table2, fieldName2); int fieldIx1 = fieldedTableMustFindFieldIx(table1, fieldName1); /* Open output and write out header */ FILE *f = mustOpen(outFile, "w"); if (table1->startsSharp) fputc('#', f); fputs(table1->fields[0], f); int i; for (i=1; i<table1->fieldCount; ++i) { fputc('\t', f); fputs(table1->fields[i], f); } for (i=0; i<table2->fieldCount; ++i) { fputc('\t', f); fputs(table2->fields[i], f); } fputc('\n', f); /* Write out rest of fields */ struct fieldedRow *row1; for (row1 = table1->rowList; row1 != NULL; row1 = row1->next) { char *key = row1->row[fieldIx1]; struct fieldedRow *row2 = hashFindVal(hash2, key); if (row2 == NULL) - errAbort("%s is found in %s.%s but not %s.%s", key, fileName1, fieldName1, - fileName2, fieldName2); + errAbort("%s is found in %s field of %s but not %s field of %s", key, fieldName1, fileName1, + fieldName2, fileName2); /* Write out data from table1 */ for (i=0; i<table1->fieldCount; ++i) { fputs(row1->row[i], f); fputc('\t', f); } /* Write out data from table 2 */ int lastField = table2->fieldCount-1; for (i=0; i<lastField; ++i) { fputs(row2->row[i], f); fputc('\t', f); } fputs(row2->row[lastField], f);