diff --git a/annot.cpp b/annot.cpp index 4db3282..648689f 100644 --- a/annot.cpp +++ b/annot.cpp @@ -17,7 +17,7 @@ void AnnotationMap::parse() { ifstream in(fname_); if(!in.good() && in.is_open()) { cerr << "Could not open annotation file " << fname_ << endl; - throw std::runtime_error(""); + throw 1; } while(in.peek() != EOF) { U32Pair pos; diff --git a/bitset.h b/bitset.h index 70cd6f1..108c79e 100644 --- a/bitset.h +++ b/bitset.h @@ -34,7 +34,7 @@ bitsetRealloc(uint32_t& sz, uint32_t* words, const char *errmsg = NULL) { // Output given error message std::cerr << errmsg; } - throw std::runtime_error(""); + throw 1; } if(oldsz > 0) { // Move old values into new array @@ -65,7 +65,7 @@ class SyncBitset { if(_errmsg != NULL) { std::cerr << _errmsg; } - throw std::runtime_error(""); + throw 1; } assert(_words != NULL); memset(_words, 0, nwords * 4 /* words to bytes */); @@ -174,7 +174,7 @@ class Bitset { if(_errmsg != NULL) { std::cerr << _errmsg; } - throw std::runtime_error(""); + throw 1; } assert(_words != NULL); memset(_words, 0, nwords * 4); diff --git a/blockwise_sa.h b/blockwise_sa.h index 188d4f3..6891f24 100644 --- a/blockwise_sa.h +++ b/blockwise_sa.h @@ -233,7 +233,7 @@ class SillyBlockwiseDnaSA : public InorderBlockwiseSA { cerr << "Out of memory creating suffix array in " << "SillyBlockwiseDnaSA::SillyBlockwiseDnaSA()" << " at " << __FILE__ << ":" << __LINE__ << endl; - std::runtime_error(""); + throw 1; } } assert_eq(length(this->text())+1, length(_sa)); @@ -482,7 +482,7 @@ void KarkkainenBlockwiseSA::buildSamples() { cerr << "Could not allocate sample suffix container of " << (numSamples * 4) << " bytes." << endl << "Please try using a smaller number of blocks by specifying a larger --bmax or" << endl << "a smaller --bmaxdivn" << endl; - std::runtime_error(""); + throw 1; } } } @@ -531,7 +531,7 @@ void KarkkainenBlockwiseSA::buildSamples() { cerr << "Could not allocate sizes, representatives (" << ((numBuckets*8)>>10) << " KB) for blocks." << endl << "Please try using a smaller number of blocks by specifying a larger --bmax or a" << endl << "smaller --bmaxdivn." << endl; - std::runtime_error(""); + throw 1; } } // Iterate through every suffix in the text, determine which @@ -844,7 +844,7 @@ void KarkkainenBlockwiseSA::nextBlock() { cerr << "Could not allocate a master suffix-array block of " << ((len+1) * 4) << " bytes" << endl << "Please try using a larger number of blocks by specifying a smaller --bmax or" << endl << "a larger --bmaxdivn" << endl; - std::runtime_error(""); + throw 1; } } } else { @@ -860,7 +860,7 @@ void KarkkainenBlockwiseSA::nextBlock() { cerr << "Could not allocate a suffix-array block of " << ((this->bucketSz()+1) * 4) << " bytes" << endl; cerr << "Please try using a larger number of blocks by specifying a smaller --bmax or" << endl << "a larger --bmaxdivn" << endl; - std::runtime_error(""); + throw 1; } } // Select upper and lower bounds from _sampleSuffs[] and @@ -899,7 +899,7 @@ void KarkkainenBlockwiseSA::nextBlock() { cerr << "Could not allocate a z-array of " << (_dcV * 4) << " bytes" << endl; cerr << "Please try using a larger number of blocks by specifying a smaller --bmax or" << endl << "a larger --bmaxdivn" << endl; - std::runtime_error(""); + throw 1; } } @@ -942,7 +942,7 @@ void KarkkainenBlockwiseSA::nextBlock() { cerr << "Could not append element to block of " << ((length(bucket)) * 4) << " bytes" << endl; cerr << "Please try using a larger number of blocks by specifying a smaller --bmax or" << endl << "a larger --bmaxdivn" << endl; - std::runtime_error(""); + throw 1; } } // Not necessarily true; we allow overflowing buckets diff --git a/bowtie_inspect.cpp b/bowtie_inspect.cpp index 21a5796..746e9d6 100644 --- a/bowtie_inspect.cpp +++ b/bowtie_inspect.cpp @@ -16,13 +16,17 @@ static int verbose = 0; // be talkative static int names_only = 0; // just print the sequence names in the index static int across = 60; // number of characters across in FASTA output -static const char *short_options = "vh?na:"; +static const char *short_options = "vhna:"; -static const int ARG_VERSION = 256; +enum { + ARG_VERSION = 256, + ARG_USAGE +}; static struct option long_options[] = { {(char*)"verbose", no_argument, 0, 'v'}, {(char*)"version", no_argument, 0, ARG_VERSION}, + {(char*)"usage", no_argument, 0, ARG_USAGE}, {(char*)"names", no_argument, 0, 'n'}, {(char*)"help", no_argument, 0, 'h'}, {(char*)"across", required_argument, 0, 'a'}, @@ -41,6 +45,7 @@ static void printUsage(ostream& out) { << " -n/--names Print reference sequence names only" << endl << " -v/--verbose Verbose output (for debugging)" << endl << " -h/--help print detailed description of tool and its options" << endl + << " --help print this usage message" << endl ; } @@ -108,13 +113,13 @@ static int parseInt(int lower, const char *errmsg) { if (l < lower) { cerr << errmsg << endl; printUsage(cerr); - throw std::runtime_error(""); + throw 1; } return (int32_t)l; } cerr << errmsg << endl; printUsage(cerr); - throw std::runtime_error(""); + throw 1; return -1; } @@ -122,19 +127,23 @@ static int parseInt(int lower, const char *errmsg) { * Read command-line arguments */ static void parseOptions(int argc, char **argv) { - int option_index = 0; + int option_index = 0; int next_option; do { next_option = getopt_long(argc, argv, short_options, long_options, &option_index); switch (next_option) { - case 'h': - case '?': { - printLongUsage(cout); - throw std::runtime_error(""); - break; - } - case 'v': verbose = true; break; - case ARG_VERSION: showVersion = true; break; + case ARG_USAGE: { + printUsage(cout); + throw 0; + break; + } + case 'h': { + printLongUsage(cout); + throw 0; + break; + } + case 'v': verbose = true; break; + case ARG_VERSION: showVersion = true; break; case 'n': names_only = true; break; case 'a': across = parseInt(-1, "-a/--across arg must be at least 1"); break; case -1: break; /* Done with options. */ @@ -142,9 +151,8 @@ static void parseOptions(int argc, char **argv) { if (long_options[option_index].flag != 0) break; default: - cerr << "Unknown option: " << (char)next_option << endl; printUsage(cerr); - throw std::runtime_error(""); + throw 1; } } while(next_option != -1); } @@ -322,6 +330,16 @@ int main(int argc, char **argv) { driver(ebwtFile, query); return 0; } catch(std::exception& e) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; return 1; + } catch(int e) { + if(e != 0) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; + } + return e; } } diff --git a/ebwt.cpp b/ebwt.cpp index de2306e..4d1fa46 100644 --- a/ebwt.cpp +++ b/ebwt.cpp @@ -59,7 +59,7 @@ string adjustEbwtBase(const string& cmdline, } if(!in.is_open()) { cerr << "Could not locate a Bowtie index corresponding to basename \"" << ebwtFileBase << "\"" << endl; - throw std::runtime_error(""); + throw 1; } return str; } diff --git a/ebwt.h b/ebwt.h index aba36d2..bcfab79 100644 --- a/ebwt.h +++ b/ebwt.h @@ -414,14 +414,14 @@ class Ebwt { cerr << "Could not open index file for writing: \"" << _in1Str << "\"" << endl << "Please make sure the directory exists and that permissions allow writing by" << endl << "Bowtie." << endl; - throw std::runtime_error(""); + throw 1; } ofstream fout2(_in2Str.c_str(), ios::binary); if(!fout2.good()) { cerr << "Could not open index file for writing: \"" << _in2Str << "\"" << endl << "Please make sure the directory exists and that permissions allow writing by" << endl << "Bowtie." << endl; - throw std::runtime_error(""); + throw 1; } // Build initFromVector(is, @@ -458,7 +458,7 @@ class Ebwt { } if(err) { cerr << "Please check if there is a problem with the disk or if disk is full." << endl; - throw std::runtime_error(""); + throw 1; } // Reopen as input streams VMSG_NL("Re-opening _in1 and _in2 as input streams"); @@ -542,7 +542,7 @@ class Ebwt { cerr << "If this computer has more than 4 GB of memory, try using a 64-bit executable;" << endl << "this executable is 32-bit." << endl; } - throw std::runtime_error(""); + throw 1; } // Succesfully obtained joined reference string assert_geq(length(s), jlen); @@ -579,7 +579,7 @@ class Ebwt { cerr << "If this computer has more than 4 GB of memory, try using a 64-bit executable;" << endl << "this executable is 32-bit." << endl; } - throw std::runtime_error(""); + throw 1; } if((iter % 6) == 5 && dcv < 4096 && dcv != 0) { dcv <<= 1; // double difference-cover period @@ -629,7 +629,7 @@ class Ebwt { out1.flush(); out2.flush(); if(out1.fail() || out2.fail()) { cerr << "An error occurred writing the index to disk. Please check if the disk is full." << endl; - throw std::runtime_error(""); + throw 1; } break; } catch(bad_alloc& e) { @@ -638,7 +638,7 @@ class Ebwt { } else { cerr << "Out of memory while constructing suffix array. Please try using a smaller" << endl << "number of blocks by specifying a smaller --bmax or a larger --bmaxdivn" << endl; - throw std::runtime_error(""); + throw 1; } } first = false; @@ -653,7 +653,7 @@ class Ebwt { out1.flush(); out2.flush(); if(out1.fail() || out2.fail()) { cerr << "An error occurred writing the index to disk. Please check if the disk is full." << endl; - throw std::runtime_error(""); + throw 1; } VMSG_NL("Returning from initFromVector"); } @@ -2730,14 +2730,14 @@ void Ebwt::readIntoMemory(bool justHeader, if (stat(names[i], &sbuf) == -1) { perror("stat"); cerr << "Error: Could not stat index file " << names[i] << " prior to memory-mapping" << endl; - throw std::runtime_error(""); + throw 1; } mmFile[i] = (char*)mmap((void *)0, sbuf.st_size, PROT_READ, MAP_SHARED, fds[i], 0); if(mmFile == (void *)(-1)) { perror("mmap"); cerr << "Error: Could not memory-map the index file " << names[i] << endl; - throw std::runtime_error(""); + throw 1; } if(mmSweep) { int sum = 0; @@ -2793,7 +2793,7 @@ void Ebwt::readIntoMemory(bool justHeader, // or we might be setting up a race condition with other processes. if(switchEndian && _useMm) { cerr << "Error: Can't use memory-mapped files when the index is the opposite endianness" << endl; - throw std::runtime_error(""); + throw 1; } // Reads header entries one by one from primary stream @@ -2860,7 +2860,7 @@ void Ebwt::readIntoMemory(bool justHeader, // into their own memory spaces. if(_useMm && (offRateDiff || isaRateDiff)) { cerr << "Error: Can't use memory-mapped files when the offrate or isarate is overridden" << endl; - throw std::runtime_error(""); + throw 1; } // Read nPat from primary stream @@ -2894,7 +2894,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in1, (void*)this->_plen, this->_nPat*4); if(r != (MM_READ_RET)(this->_nPat*4)) { cerr << "Error reading _plen[] array: " << r << ", " << (this->_nPat*4) << endl; - throw std::runtime_error(""); + throw 1; } } } catch(bad_alloc& e) { @@ -2939,7 +2939,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in1, (void *)this->_rstarts, this->_nFrag*4*3); if(r != (MM_READ_RET)(this->_nFrag*4*3)) { cerr << "Error reading _rstarts[] array: " << r << ", " << (this->_nFrag*4*3) << endl; - throw std::runtime_error(""); + throw 1; } } } @@ -2972,7 +2972,7 @@ void Ebwt::readIntoMemory(bool justHeader, << "Bowtie without the -z option, try adding the -z option to save memory. If the" << endl << "-z option does not solve the problem, please try again on a computer with more" << endl << "memory." << endl; - throw std::runtime_error(""); + throw 1; } } if(shmemLeader) { @@ -2980,7 +2980,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in1, (void *)this->_ebwt, eh->_ebwtTotLen); if(r != (MM_READ_RET)eh->_ebwtTotLen) { cerr << "Error reading _ebwt[] array: " << r << ", " << (eh->_ebwtTotLen) << endl; - throw std::runtime_error(""); + throw 1; } if(switchEndian) { uint8_t *side = this->_ebwt; @@ -3042,7 +3042,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in1, (void *)this->_ftab, eh->_ftabLen*4); if(r != (MM_READ_RET)(eh->_ftabLen*4)) { cerr << "Error reading _ftab[] array: " << r << ", " << (eh->_ftabLen*4) << endl; - throw std::runtime_error(""); + throw 1; } } } @@ -3066,7 +3066,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in1, (void *)this->_eftab, eh->_eftabLen*4); if(r != (MM_READ_RET)(eh->_eftabLen*4)) { cerr << "Error reading _eftab[] array: " << r << ", " << (eh->_eftabLen*4) << endl; - throw std::runtime_error(""); + throw 1; } } } @@ -3082,7 +3082,7 @@ void Ebwt::readIntoMemory(bool justHeader, << "If you ran Bowtie without the -z option, try adding the -z option to save" << endl << "memory. If the -z option does not solve the problem, please try again on a" << endl << "computer with more memory." << endl; - throw std::runtime_error(""); + throw 1; } // Read reference sequence names from primary index file (or not, @@ -3121,7 +3121,7 @@ void Ebwt::readIntoMemory(bool justHeader, << "If you ran Bowtie without the -z option, try adding the -z option to save" << endl << "memory. If the -z option does not solve the problem, please try again on a" << endl << "computer with more memory." << endl; - throw std::runtime_error(""); + throw 1; } } else { shmemLeader = ALLOC_SHARED_U32( @@ -3143,7 +3143,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in2, (void *)buf, block << 2); if(r != (MM_READ_RET)(block << 2)) { cerr << "Error reading block of _offs[] array: " << r << ", " << (block << 2) << endl; - throw std::runtime_error(""); + throw 1; } uint32_t idx = i >> offRateDiff; for(uint32_t j = 0; j < block; j += (1 << offRateDiff)) { @@ -3168,7 +3168,7 @@ void Ebwt::readIntoMemory(bool justHeader, if((offsLen & 0xc0000000) != 0) { if(sizeof(char *) <= 4) { cerr << "Sanity error: sizeof(char *) <= 4 but offsLen is " << hex << offsLen << endl; - throw std::runtime_error(""); + throw 1; } // offsLen << 2 overflows, so do it in four reads char *offs = (char *)this->_offs; @@ -3176,7 +3176,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in2, (void*)offs, offsLen); if(r != (MM_READ_RET)(offsLen)) { cerr << "Error reading block of _offs[] array: " << r << ", " << offsLen << endl; - throw std::runtime_error(""); + throw 1; } offs += offsLen; } @@ -3185,7 +3185,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in2, (void*)this->_offs, offsLen << 2); if(r != (MM_READ_RET)(offsLen << 2)) { cerr << "Error reading _offs[] array: " << r << ", " << (offsLen << 2) << endl; - throw std::runtime_error(""); + throw 1; } } } @@ -3221,7 +3221,7 @@ void Ebwt::readIntoMemory(bool justHeader, << "If you ran Bowtie without the -z option, try adding the -z option to save" << endl << "memory. If the -z option does not solve the problem, please try again on a" << endl << "computer with more memory." << endl; - throw std::runtime_error(""); + throw 1; } } // Read _isa[] @@ -3233,7 +3233,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in2, (void *)tmp, 4); if(r != (MM_READ_RET)4) { cerr << "Error reading a word of the _isa[] array: " << r << ", 4" << endl; - throw std::runtime_error(""); + throw 1; } } else { uint32_t idx = i >> isaRateDiff; @@ -3252,7 +3252,7 @@ void Ebwt::readIntoMemory(bool justHeader, MM_READ_RET r = MM_READ(_in2, (void *)this->_isa, isaLen*4); if(r != (MM_READ_RET)(isaLen*4)) { cerr << "Error reading _isa[] array: " << r << ", " << (isaLen*4) << endl; - throw std::runtime_error(""); + throw 1; } } } diff --git a/ebwt_build.cpp b/ebwt_build.cpp index cbe6bf8..f8eab0a 100644 --- a/ebwt_build.cpp +++ b/ebwt_build.cpp @@ -77,15 +77,18 @@ static void resetOptions() { } // Argument constants for getopts -static const int ARG_BMAX = 256; -static const int ARG_BMAX_MULT = 257; -static const int ARG_BMAX_DIV = 258; -static const int ARG_DCV = 259; -static const int ARG_SEED = 260; -static const int ARG_CUTOFF = 261; -static const int ARG_PMAP = 262; -static const int ARG_ISARATE = 263; -static const int ARG_NTOA = 264; +enum { + ARG_BMAX = 256, + ARG_BMAX_MULT, + ARG_BMAX_DIV, + ARG_DCV, + ARG_SEED, + ARG_CUTOFF, + ARG_PMAP, + ARG_ISARATE, + ARG_NTOA, + ARG_USAGE +}; /** * Print a detailed usage message to the provided output stream. @@ -118,6 +121,7 @@ static void printUsage(ostream& out) { << " -q/--quiet verbose output (for debugging)" << endl //<< " -s/--sanity enable sanity checks (much slower/increased memory usage)" << endl << " -h/--help print detailed description of tool and its options" << endl + << " --usage print this usage message" << endl << " --version print version information and quit" << endl ; } @@ -367,6 +371,7 @@ static struct option long_options[] = { {(char*)"ntoa", no_argument, 0, ARG_NTOA}, {(char*)"justref", no_argument, 0, '3'}, {(char*)"noref", no_argument, 0, 'r'}, + {(char*)"usage", no_argument, 0, ARG_USAGE}, {(char*)0, 0, 0, 0} // terminator }; @@ -383,13 +388,13 @@ static int parseNumber(T lower, const char *errmsg) { if (t < lower) { cerr << errmsg << endl; printUsage(cerr); - std::runtime_error(""); + throw 1; } return t; } cerr << errmsg << endl; printUsage(cerr); - std::runtime_error(""); + throw 1; return -1; } @@ -431,11 +436,11 @@ static void parseOptions(int argc, const char **argv) { break; case 'h': printLongUsage(cout); - throw std::runtime_error(""); + throw 0; break; - case '?': - printUsage(cerr); - throw std::runtime_error(""); + case ARG_USAGE: + printUsage(cout); + throw 0; break; case ARG_BMAX: bmax = parseNumber(1, "--bmax arg must be at least 1"); @@ -473,9 +478,8 @@ static void parseOptions(int argc, const char **argv) { if (long_options[option_index].flag != 0) break; default: - cerr << "Unknown option: " << (char)next_option << endl; printUsage(cerr); - std::runtime_error(""); + throw 1; } } while(next_option != -1); if(bmax < 40) { @@ -517,7 +521,7 @@ static void driver(const string& infile, FILE *f = fopen(infiles[i].c_str(), "r"); if (f == NULL) { cerr << "Error: could not open "<< infiles[i] << endl; - std::runtime_error(""); + throw 1; } FileBuf *fb = new FileBuf(f); assert(fb != NULL); @@ -549,7 +553,7 @@ static void driver(const string& infile, cerr << "Could not open index file for writing: \"" << file3 << "\"" << endl << "Please make sure the directory exists and that permissions allow writing by" << endl << "Bowtie." << endl; - std::runtime_error(""); + throw 1; } bool be = currentlyBigEndian(); writeU32(fout3, 1, be); // endianness sentinel @@ -774,7 +778,17 @@ int bowtie_build(int argc, const char **argv) { } return 0; } catch(std::exception& e) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; return 1; + } catch(int e) { + if(e != 0) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; + } + return e; } } } diff --git a/ebwt_search.cpp b/ebwt_search.cpp index fa954b6..76dc164 100644 --- a/ebwt_search.cpp +++ b/ebwt_search.cpp @@ -241,7 +241,7 @@ static void resetOptions() { // mating constraints -static const char *short_options = "fF:qbzh?cu:rv:s:at3:5:o:e:n:l:w:p:k:m:1:2:I:X:x:B:yS"; +static const char *short_options = "fF:qbzhcu:rv:s:at3:5:o:e:n:l:w:p:k:m:1:2:I:X:x:B:yS"; enum { ARG_ORIG = 256, @@ -317,7 +317,8 @@ enum { ARG_REPORTSE, ARG_HADOOPOUT, ARG_FUZZY, - ARG_FULLREF + ARG_FULLREF, + ARG_USAGE }; static struct option long_options[] = { @@ -422,6 +423,7 @@ static struct option long_options[] = { {(char*)"hadoopout", no_argument, 0, ARG_HADOOPOUT}, {(char*)"fuzzy", no_argument, 0, ARG_FUZZY}, {(char*)"fullref", no_argument, 0, ARG_FULLREF}, + {(char*)"usage", no_argument, 0, ARG_USAGE}, {(char*)"sam", no_argument, 0, 'S'}, {(char*)0, 0, 0, 0} // terminator }; @@ -503,6 +505,7 @@ static void printUsage(ostream& out) { << " --verbose verbose output (for debugging)" << endl << " --version print version information and quit" << endl << " -h/--help print detailed description of tool and its options" << endl + << " --usage print this usage message" << endl ; } @@ -1456,13 +1459,13 @@ static int parseInt(int lower, const char *errmsg) { if (l < lower) { cerr << errmsg << endl; printUsage(cerr); - throw std::runtime_error(""); + throw 1; } return (int32_t)l; } cerr << errmsg << endl; printUsage(cerr); - throw std::runtime_error(""); + throw 1; return -1; } @@ -1555,7 +1558,7 @@ static void parseOptions(int argc, const char **argv) { << "BOWTIE_MM defined. Memory-mapped I/O is not supported under Windows. If you" << endl << "would like to use memory-mapped I/O on a platform that supports it, please" << endl << "refrain from specifying BOWTIE_MM=0 when compiling Bowtie." << endl; - throw std::runtime_error(""); + throw 1; #endif } case ARG_MMSWEEP: mmSweep = true; break; @@ -1618,14 +1621,14 @@ static void parseOptions(int argc, const char **argv) { case 'p': #ifndef BOWTIE_PTHREADS cerr << "-p/--threads is disabled because bowtie was not compiled with pthreads support" << endl; - throw std::runtime_error(""); + throw 1; #endif nthreads = parseInt(1, "-p/--threads arg must be at least 1"); break; case ARG_FILEPAR: #ifndef BOWTIE_PTHREADS cerr << "--filepar is disabled because bowtie was not compiled with pthreads support" << endl; - throw std::runtime_error(""); + throw 1; #endif fileParallel = true; break; @@ -1634,7 +1637,7 @@ static void parseOptions(int argc, const char **argv) { mismatches = parseInt(0, "-v arg must be at least 0"); if(mismatches > 3) { cerr << "-v arg must be at most 3" << endl; - throw std::runtime_error(""); + throw 1; } break; case '3': trim3 = parseInt(0, "-3/--trim3 arg must be at least 0"); break; @@ -1644,8 +1647,8 @@ static void parseOptions(int argc, const char **argv) { case 'e': qualThresh = parseInt(1, "-e/--err arg must be at least 1"); break; case 'n': seedMms = parseInt(0, "-n/--seedmms arg must be at least 0"); maqLike = 1; break; case 'l': seedLen = parseInt(5, "-l/--seedlen arg must be at least 5"); break; - case 'h': printLongUsage(cout); throw std::runtime_error(""); break; - case '?': printUsage(cerr); throw std::runtime_error(""); break; + case 'h': printLongUsage(cout); throw 0; break; + case ARG_USAGE: printUsage(cout); throw 0; break; case 'a': allHits = true; break; case 'y': tryHard = true; break; case ARG_RECAL: recal = true; break; @@ -1678,7 +1681,7 @@ static void parseOptions(int argc, const char **argv) { if(optarg == NULL || strlen(optarg) == 0) { cerr << "--orig arg must be followed by a string" << endl; printUsage(cerr); - throw std::runtime_error(""); + throw 1; } origString = optarg; break; @@ -1687,9 +1690,8 @@ static void parseOptions(int argc, const char **argv) { if (long_options[option_index].flag != 0) break; default: - cerr << "Unknown option: " << (char)next_option << endl; printUsage(cerr); - throw std::runtime_error(""); + throw 1; } } while(next_option != -1); bool paired = mates1.size() > 0 || mates2.size() > 0 || mates12.size() > 0; @@ -1710,7 +1712,7 @@ static void parseOptions(int argc, const char **argv) { cerr << "Error: " << mates1.size() << " mate files/sequences were specified with -1, but " << mates2.size() << endl << "mate files/sequences were specified with -2. The same number of mate files/" << endl << "sequences must be specified with -1 and -2." << endl; - throw std::runtime_error(""); + throw 1; } // Check for duplicate mate input files if(format != CMDLINE) { @@ -1762,7 +1764,7 @@ static void parseOptions(int argc, const char **argv) { cerr << "When -z/--phased is used, the --al option is unavailable" << endl; error = true; } - if(error) throw std::runtime_error(""); + if(error) throw 1; } if(tryHard) { // Increase backtracking limit to huge number @@ -1772,15 +1774,15 @@ static void parseOptions(int argc, const char **argv) { } if(fullIndex && strata && !stateful && !oldBest) { cerr << "--strata must be combined with --best" << endl; - throw std::runtime_error(""); + throw 1; } if(strata && !allHits && khits == 1 && mhits == 0xffffffff) { cerr << "--strata has no effect unless combined with -k, -m or -a" << endl; - throw std::runtime_error(""); + throw 1; } if(fuzzy && (!stateful && !paired)) { cerr << "--fuzzy must be combined with --best or paired-end alignment" << endl; - throw std::runtime_error(""); + throw 1; } // If both -s and -u are used, we need to adjust qUpto accordingly // since it uses patid to know if we've reached the -u limit (and @@ -1802,7 +1804,7 @@ static void parseOptions(int argc, const char **argv) { cerr << "Error: --chainin cannot be combined with paired-end alignment; aborting..." << endl; error = true; } - if(error) throw std::runtime_error(""); + if(error) throw 1; } if(outType == OUTPUT_CHAIN) { @@ -1819,7 +1821,7 @@ static void parseOptions(int argc, const char **argv) { cerr << "Error: --chainout cannot be combined with paired-end alignment; aborting..." << endl; error = true; } - if(error) throw std::runtime_error(""); + if(error) throw 1; } if(mate1fw && trim5 > 0) { @@ -2221,7 +2223,7 @@ static void exactSearch(PairedPatternSource& _patsrc, if((mates1.size() > 0 || mates12.size() > 0) && mixedThresh < 0xffffffff) { Timer _t(cerr, "Time loading reference: ", timing); refs = new BitPairReference(adjustedEbwtFileBase, sanityCheck, NULL, &os, false, useMm, useShmem, mmSweep, verbose, startVerbose); - if(!refs->loaded()) throw std::runtime_error(""); + if(!refs->loaded()) throw 1; } exactSearch_refs = refs; @@ -2253,7 +2255,7 @@ static void exactSearch(PairedPatternSource& _patsrc, int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -2443,7 +2445,7 @@ static void mismatchSearch(PairedPatternSource& _patsrc, int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -2478,7 +2480,7 @@ static void mismatchSearch(PairedPatternSource& _patsrc, int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -2660,7 +2662,7 @@ static void mismatchSearchFull(PairedPatternSource& _patsrc, if((mates1.size() > 0 || mates12.size() > 0) && mixedThresh < 0xffffffff) { Timer _t(cerr, "Time loading reference: ", timing); refs = new BitPairReference(adjustedEbwtFileBase, sanityCheck, NULL, &os, false, useMm, useShmem, mmSweep, verbose, startVerbose); - if(!refs->loaded()) throw std::runtime_error(""); + if(!refs->loaded()) throw 1; } mismatchSearch_refs = refs; @@ -2693,7 +2695,7 @@ static void mismatchSearchFull(PairedPatternSource& _patsrc, int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -3031,7 +3033,7 @@ static void twoOrThreeMismatchSearch( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -3052,7 +3054,7 @@ static void twoOrThreeMismatchSearch( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -3072,7 +3074,7 @@ static void twoOrThreeMismatchSearch( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -3280,7 +3282,7 @@ static void twoOrThreeMismatchSearchFull( if((mates1.size() > 0 || mates12.size() > 0) && mixedThresh < 0xffffffff) { Timer _t(cerr, "Time loading reference: ", timing); refs = new BitPairReference(adjustedEbwtFileBase, sanityCheck, NULL, &os, false, useMm, useShmem, mmSweep, verbose, startVerbose); - if(!refs->loaded()) throw std::runtime_error(""); + if(!refs->loaded()) throw 1; } twoOrThreeMismatchSearch_refs = refs; twoOrThreeMismatchSearch_patsrc = &_patsrc; @@ -3319,7 +3321,7 @@ static void twoOrThreeMismatchSearchFull( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -3949,7 +3951,7 @@ static void seededQualCutoffSearch( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -3962,7 +3964,7 @@ static void seededQualCutoffSearch( } catch(bad_alloc& ba) { cerr << "Could not reserve space for PartialAlignmentManager" << endl; cerr << "Please subdivide the read set and invoke bowtie separately for each subdivision" << endl; - throw std::runtime_error(""); + throw 1; } seededQualSearch_pamRc = pamRc; { @@ -3985,7 +3987,7 @@ static void seededQualCutoffSearch( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -4004,7 +4006,7 @@ static void seededQualCutoffSearch( } catch(bad_alloc& ba) { cerr << "Could not reserve space for PartialAlignmentManager" << endl; cerr << "Please subdivide the read set and invoke bowtie separately for each subdivision" << endl; - throw std::runtime_error(""); + throw 1; } seededQualSearch_pamFw = pamFw; { @@ -4023,7 +4025,7 @@ static void seededQualCutoffSearch( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -4051,7 +4053,7 @@ static void seededQualCutoffSearch( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -4114,7 +4116,7 @@ static void seededQualCutoffSearchFull( if((mates1.size() > 0 || mates12.size() > 0) && mixedThresh < 0xffffffff) { Timer _t(cerr, "Time loading reference: ", timing); refs = new BitPairReference(adjustedEbwtFileBase, sanityCheck, NULL, &os, false, useMm, useShmem, mmSweep, verbose, startVerbose); - if(!refs->loaded()) throw std::runtime_error(""); + if(!refs->loaded()) throw 1; } seededQualSearch_refs = refs; @@ -4156,7 +4158,7 @@ static void seededQualCutoffSearchFull( int ret; if((ret = pthread_join(threads[i], NULL)) != 0) { cerr << "Error: pthread_join returned non-zero status: " << ret << endl; - throw std::runtime_error(""); + throw 1; } } #endif @@ -4231,7 +4233,7 @@ patsrcFromStrings(int format, const vector& qs) { verbose, seed); default: { cerr << "Internal error; bad patsrc format: " << format << endl; - throw std::runtime_error(""); + throw 1; } } } @@ -4293,7 +4295,7 @@ static void driver(const char * type, for(size_t i = 0; i < mates12.size(); i++) { if(mates12[i] == "-" && !fullIndex) { cerr << "Input file \"-\" is not compatible with -z/--phased" << endl; - throw std::runtime_error(""); + throw 1; } const vector* qs = &mates12; vector tmp; @@ -4313,7 +4315,7 @@ static void driver(const char * type, for(size_t i = 0; i < mates1.size(); i++) { if(mates1[i] == "-" && !fullIndex) { cerr << "Input file \"-\" is not compatible with -z/--phased" << endl; - throw std::runtime_error(""); + throw 1; } const vector* qs = &mates1; vector tmp; @@ -4333,7 +4335,7 @@ static void driver(const char * type, for(size_t i = 0; i < mates2.size(); i++) { if(mates2[i] == "-" && !fullIndex) { cerr << "Input file \"-\" is not compatible with -z/--phased" << endl; - throw std::runtime_error(""); + throw 1; } const vector* qs = &mates2; vector tmp; @@ -4358,7 +4360,7 @@ static void driver(const char * type, for(size_t i = 0; i < queries.size(); i++) { if(queries[i] == "-" && !fullIndex) { cerr << "Input file \"-\" is not compatible with -z/--phased" << endl; - throw std::runtime_error(""); + throw 1; } const vector* qs = &queries; PatternSource* patsrc = NULL; @@ -4405,11 +4407,11 @@ static void driver(const char * type, } else { if(outType == OUTPUT_BINARY && !refOut) { cerr << "Error: Must specify an output file when output mode is binary" << endl; - throw std::runtime_error(""); + throw 1; } else if(outType == OUTPUT_CHAIN) { cerr << "Error: Must specify an output file when output mode is --chain" << endl; - throw std::runtime_error(""); + throw 1; } fout = new OutFileBuf(); } @@ -4569,7 +4571,7 @@ static void driver(const char * type, break; default: cerr << "Invalid output type: " << outType << endl; - throw std::runtime_error(""); + throw 1; } if(verbose || startVerbose) { cerr << "Dispatching to search driver: "; logTime(cerr, true); @@ -4611,7 +4613,7 @@ static void driver(const char * type, } } else { cerr << "Error: " << mismatches << " is not a supported number of mismatches" << endl; - throw std::runtime_error(""); + throw 1; } } else { // Search without mismatches @@ -4743,7 +4745,7 @@ int bowtie(int argc, const char **argv) { cerr << "Note that if files are specified using -1/-2, a file cannot" << endl << "also be specified. Please run bowtie separately for mates and singles." << endl; } - throw std::runtime_error(""); + throw 1; } // Optionally summarize @@ -4778,6 +4780,13 @@ int bowtie(int argc, const char **argv) { for(int i = 0; i < argc; i++) cerr << argv[i] << " "; cerr << endl; return 1; + } catch(int e) { + if(e != 0) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; + } + return e; } } // bowtie() } // extern "C" diff --git a/ebwt_search_backtrack.h b/ebwt_search_backtrack.h index 3d1a23e..038a67f 100644 --- a/ebwt_search_backtrack.h +++ b/ebwt_search_backtrack.h @@ -115,7 +115,7 @@ class GreedyDFSRangeSource { cerr << "Unable to allocate memory for depth-first " << "backtracking search; new length = " << length(*_qry) << endl; - throw std::runtime_error(""); + throw 1; } } else { // New length is less than old length, so there's no need @@ -3202,7 +3202,7 @@ class EbwtRangeSourceDriver : if(cext == PIN_TO_BEGINNING) return 0; if(cext == PIN_TO_LEN) return len; cerr << "Bad SearchConstraintExtent: " << cext; - throw std::runtime_error(""); + throw 1; } bool seed_; diff --git a/filebuf.h b/filebuf.h index 24e6090..6d3bbcc 100644 --- a/filebuf.h +++ b/filebuf.h @@ -277,7 +277,7 @@ class BitpairOutFileBuf { out_ = fopen(in, "wb"); if(out_ == NULL) { std::cerr << "Error: Could not open bitpair-output file " << in << std::endl; - throw std::runtime_error(""); + throw 1; } } @@ -296,7 +296,7 @@ class BitpairOutFileBuf { // Flush the buffer if(!fwrite((const void *)buf_, BUF_SZ, 1, out_)) { std::cerr << "Error writing to the reference index file (.4.ebwt)" << std::endl; - throw std::runtime_error(""); + throw 1; } // Reset to beginning of the buffer cur_ = 0; @@ -316,7 +316,7 @@ class BitpairOutFileBuf { if(bpPtr_ == 0) cur_--; if(!fwrite((const void *)buf_, cur_ + 1, 1, out_)) { std::cerr << "Error writing to the reference index file (.4.ebwt)" << std::endl; - throw std::runtime_error(""); + throw 1; } } fclose(out_); @@ -348,7 +348,7 @@ class OutFileBuf { out_ = fopen(out, binary ? "wb" : "w"); if(out_ == NULL) { std::cerr << "Error: Could not open alignment output file " << out << std::endl; - throw std::runtime_error(""); + throw 1; } } @@ -407,7 +407,7 @@ class OutFileBuf { void flush() { if(!fwrite((const void *)buf_, cur_, 1, out_)) { std::cerr << "Error while flushing and closing output" << std::endl; - throw std::runtime_error(""); + throw 1; } cur_ = 0; } diff --git a/hit.h b/hit.h index b85868e..c8db9dd 100644 --- a/hit.h +++ b/hit.h @@ -87,27 +87,27 @@ class Hit { if(seqan::length(patName) > 0xffff) { cerr << "Error: One or more read names are 2^16 characters or longer. Please truncate" << endl << "read names and re-run bowtie." << endl; - throw std::runtime_error(""); + throw 1; } if(mms.count() > 0xff) { cerr << "Error: The alignment contains 256 or more mismatches. bowtie cannot handle" << endl << "alignments with this many alignments. Please provide smaller reads or consider" << endl << "using a different tool." << endl; - throw std::runtime_error(""); + throw 1; } if(seqan::length(quals) > 0xffff) { cerr << "Error: One or more quality strings are 2^16 characters or longer. Please" << endl << "truncate reads and re-run bowtie." << endl; - throw std::runtime_error(""); + throw 1; } if(seqan::length(patSeq) > 0xffff) { cerr << "Error: One or more read sequences are 2^16 characters or longer. Please" << endl << "truncate reads and re-run bowtie." << endl; - throw std::runtime_error(""); + throw 1; } if(stratum < 0 || stratum >= 4) { cerr << "Error: Stratum is out of bounds: " << stratum << endl; - throw std::runtime_error(""); + throw 1; } } @@ -277,7 +277,7 @@ class RecalTable { memset(ents_, 0, len_ << 2); } catch(std::bad_alloc& e) { cerr << "Error allocating recalibration table with " << len_ << " entries" << endl; - throw std::runtime_error(""); + throw 1; } } } @@ -1075,7 +1075,7 @@ class HitSink { s = name.substr(0, dotoff) + "_2" + s.substr(dotoff); } } else if(mateType != 0) { - cerr << "Bad mate type " << mateType << endl; throw std::runtime_error(""); + cerr << "Bad mate type " << mateType << endl; throw 1; } std::ofstream* tmp = new ofstream(s.c_str(), ios::out); if(tmp->fail()) { @@ -1084,7 +1084,7 @@ class HitSink { } else { cerr << "Could not open paired-end aligned/unaligned-read file for writing: " << name << endl; } - throw std::runtime_error(""); + throw 1; } return tmp; } @@ -1339,7 +1339,7 @@ class HitSinkPerThread { virtual bool setHits(HitSet& hs) { if(!hs.empty()) { cerr << "Error: default setHits() called with non-empty HitSet" << endl; - throw std::runtime_error(""); + throw 1; } return false; } @@ -2730,11 +2730,11 @@ class VerboseHitSink : public HitSink { } if(in.bad()) { cerr << "Alignment file set \"bad\" bit" << endl; - throw std::runtime_error(""); + throw 1; } if(in.fail()) { cerr << "A line from the alignment file was longer than 4K" << endl; - throw std::runtime_error(""); + throw 1; } in.getline(buf, 4096); size_t len = in.gcount(); @@ -2830,7 +2830,7 @@ class VerboseHitSink : public HitSink { if(!found) { cerr << "Could not find an id to map reference name \"" << refName << "\" to." << endl << "Try using -n to specify the index used to generate the alignments." << endl; - throw std::runtime_error(""); + throw 1; } } @@ -3446,7 +3446,7 @@ class ChainingHitSink : public HitSink { */ virtual void append(ostream& o, const Hit& h) { cerr << "Error: ChainingHitSink::append() not implemented" << endl; - throw std::runtime_error(""); + throw 1; } /** diff --git a/map_tool.cpp b/map_tool.cpp index 9c5624b..4b299c8 100644 --- a/map_tool.cpp +++ b/map_tool.cpp @@ -127,6 +127,7 @@ static void printUsage(ostream& out) { << " -n/--names if needed, get ref names from index w/ basename " << endl << " -v/--verbose verbose output (for debugging)" << endl << " -h/--help print detailed description of tool and its options" << endl + << " --usage print detailed description of tool and its options" << endl << " --version print version information and quit" << endl ; } @@ -135,7 +136,8 @@ static const char *short_options = "hvsdbsDBCQFn:"; enum { ARG_VERSION = 256, - ARG_REFIDX + ARG_REFIDX, + ARG_USAGE }; static struct option long_options[] = { @@ -152,6 +154,7 @@ static struct option long_options[] = { {(char*)"help", no_argument, 0, 'h'}, {(char*)"refidx", no_argument, 0, ARG_REFIDX}, {(char*)"version", no_argument, 0, ARG_VERSION}, + {(char*)"usage", no_argument, 0, ARG_USAGE}, {(char*)0, 0, 0, 0} // terminator }; @@ -165,9 +168,12 @@ static void parseOptions(int argc, char **argv) { next_option = getopt_long(argc, argv, short_options, long_options, &option_index); switch (next_option) { case 'h': - case '?': printLongUsage(cout); - throw std::runtime_error(""); + throw 0; + break; + case ARG_USAGE: + printUsage(cout); + throw 0; break; case 'v': verbose = true; break; case 's': sorthits = true; break; @@ -184,9 +190,8 @@ static void parseOptions(int argc, char **argv) { case -1: /* Done with options. */ break; case 0: if (long_options[option_index].flag != 0) break; default: - cerr << "Unknown option: " << (char)next_option << endl; printUsage(cerr); - throw runtime_error(""); + throw 1; } } while(next_option != -1); } @@ -262,7 +267,7 @@ int main(int argc, char **argv) { out = new ofstream(argv[optind]); } else if(outformat == FORMAT_BIN) { cerr << "If -B/--outbin is specified, must also be specified" << endl; - throw runtime_error(""); + throw 1; } // Read in reference names, if requested @@ -364,6 +369,16 @@ int main(int argc, char **argv) { return 0; } catch(std::exception& e) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; return 1; + } catch(int e) { + if(e != 0) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; + } + return e; } } diff --git a/maq_convert/bfa.cpp b/maq_convert/bfa.cpp index ced9914..7f545ad 100644 --- a/maq_convert/bfa.cpp +++ b/maq_convert/bfa.cpp @@ -14,7 +14,7 @@ nst_bfa1_t *nst_new_bfa1() bfa1 = (nst_bfa1_t*)malloc(sizeof(nst_bfa1_t)); if(bfa1 == NULL) { cerr << "Exhausted memory allocating space for the .bfa file" << endl; - throw std::runtime_error(""); + throw 1; } bfa1->name = 0; bfa1->seq = bfa1->mask = 0; @@ -31,7 +31,7 @@ void nst_delete_bfa1(nst_bfa1_t *bfa1) } static void bfa_read_error() { fprintf(stderr, "Error reading from .bfa file\n"); - throw std::runtime_error(""); + throw 1; } nst_bfa1_t *nst_load_bfa1(FILE *fp) { @@ -42,7 +42,7 @@ nst_bfa1_t *nst_load_bfa1(FILE *fp) bfa1->name = (char*)malloc(sizeof(char) * len); if(bfa1->name == NULL) { cerr << "Exhausted memory allocating space for the .bfa file name" << endl; - throw std::runtime_error(""); + throw 1; } /* * BTL: I had to add in these return-value checks to keep gcc 4.3.2 @@ -60,7 +60,7 @@ nst_bfa1_t *nst_load_bfa1(FILE *fp) bfa1->seq = (bit64_t*)malloc(sizeof(bit64_t) * bfa1->len); if(bfa1->seq == NULL) { cerr << "Exhausted memory allocating space for the .bfa file sequence" << endl; - throw std::runtime_error(""); + throw 1; } if(fread(bfa1->seq, sizeof(bit64_t), bfa1->len, fp) != (size_t)bfa1->len) { bfa_read_error(); @@ -68,7 +68,7 @@ nst_bfa1_t *nst_load_bfa1(FILE *fp) bfa1->mask = (bit64_t*)malloc(sizeof(bit64_t) * bfa1->len); if(bfa1->mask == NULL) { cerr << "Exhausted memory allocating space for the .bfa file mask" << endl; - throw std::runtime_error(""); + throw 1; } if(fread(bfa1->mask, sizeof(bit64_t), bfa1->len, fp) != (size_t)bfa1->len) { bfa_read_error(); diff --git a/maq_convert/bowtie_convert.cpp b/maq_convert/bowtie_convert.cpp index f431b37..da09541 100644 --- a/maq_convert/bowtie_convert.cpp +++ b/maq_convert/bowtie_convert.cpp @@ -86,7 +86,7 @@ static void printLongUsage(ostream& out) { "\n" " -v Print verbose output (for debugging).\n" "\n" - " -h/-? Print detailed description of tool and its options\n" + " -h Print detailed description of tool and its options\n" " (from MANUAL).\n" "\n" ; @@ -102,7 +102,7 @@ static void printUsage(ostream& out) { "Options:\n" " -o output Maq map in old (pre Maq 0.7.0) format\n" " -v verbose output\n" - " -h/-? print detailed description of tool and its options\n" + " -h print detailed description of tool and its options\n" "\n" ; } @@ -196,14 +196,14 @@ int convert_bwt_to_maq(const string& bwtmap_fname, if (!bwtf) { fprintf(stderr, "Error: could not open Bowtie mapfile %s for reading\n", bwtmap_fname.c_str()); - throw std::runtime_error(""); + throw 1; } void* maqf = gzopen(maqmap_fname.c_str(), "w"); if (!maqf) { fprintf(stderr, "Error: could not open Maq mapfile %s for writing\n", maqmap_fname.c_str()); - throw std::runtime_error(""); + throw 1; } std::map seqid_to_name; @@ -287,7 +287,7 @@ int convert_bwt_to_maq(const string& bwtmap_fname, (aln_t*)malloc(sizeof(aln_t) * (next_max)); if(tmp == NULL) { cerr << "Memory exhausted allocating space for alignments." << endl; - throw std::runtime_error(""); + throw 1; } memcpy(tmp, mm->mapped_reads, sizeof(aln_t) * (max)); free(mm->mapped_reads); @@ -420,7 +420,7 @@ int convert_bwt_to_maq(const string& bwtmap_fname, mm->ref_name = (char**)malloc(sizeof(char*) * mm->n_ref); if(mm->ref_name == NULL) { cerr << "Exhausted memory allocating reference name" << endl; - throw std::runtime_error(""); + throw 1; } for (map::const_iterator i = names_to_ids.begin(); @@ -463,7 +463,7 @@ void get_names_from_bfa(const string& bfa_filename, if (!bfaf) { fprintf(stderr, "Error: could not open Binary FASTA file %s for reading\n", bfa_filename.c_str()); - throw std::runtime_error(""); + throw 1; } unsigned int next_id = 0; @@ -485,7 +485,7 @@ int main(int argc, char **argv) string bwtmap_filename; string maqmap_filename; string bfa_filename; - const char *short_options = "voh?"; + const char *short_options = "voh"; int next_option; do { next_option = getopt(argc, argv, short_options); @@ -497,14 +497,13 @@ int main(int argc, char **argv) short_map_format = true; break; case 'h': - case '?': printLongUsage(cout); - throw std::runtime_error(""); + throw 0; case -1: /* Done with options. */ break; default: printUsage(cerr); - throw std::runtime_error(""); + throw 1; } } while(next_option != -1); @@ -554,6 +553,16 @@ int main(int argc, char **argv) return ret; } catch(std::exception& e) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; return 1; + } catch(int e) { + if(e != 0) { + cerr << "Command: "; + for(int i = 0; i < argc; i++) cerr << argv[i] << " "; + cerr << endl; + } + return e; } } diff --git a/maq_convert/maqmap.h b/maq_convert/maqmap.h index 0cadf64..f61397d 100644 --- a/maq_convert/maqmap.h +++ b/maq_convert/maqmap.h @@ -50,7 +50,7 @@ header_t* maq_init_header() header_t* mm = (header_t*)calloc(1, sizeof(header_t)); if(mm == NULL) { std::cerr << "Exhausted memory allocating maqmap header" << std::endl; - throw std::runtime_error(""); + throw 1; } mm->format = MAQMAP_FORMAT_NEW; return mm; @@ -96,14 +96,14 @@ header_t* maq_read_header(gzFile fp) mm->ref_name = (char**)calloc(mm->n_ref, sizeof(char*)); if(mm->ref_name == NULL) { std::cerr << "Exhausted memory allocating reference name list" << std::endl; - throw std::runtime_error(""); + throw 1; } for (k = 0; k != mm->n_ref; ++k) { gzread(fp, &len, 4); mm->ref_name[k] = (char*)malloc(len); if(mm->ref_name[k] == NULL) { std::cerr << "Exhausted memory allocating reference name" << std::endl; - throw std::runtime_error(""); + throw 1; } gzread(fp, mm->ref_name[k], len); } diff --git a/maq_convert/read_bfq.h b/maq_convert/read_bfq.h index 327cfd7..03f76ef 100644 --- a/maq_convert/read_bfq.h +++ b/maq_convert/read_bfq.h @@ -30,8 +30,8 @@ static bool ma_load_1read(gzFile fp, TStr& ret) { // Read name length if (gzread(fp, &len, sizeof(int)) != sizeof(int)) return false; if(len > 2047) { - throw std::runtime_error( - "One or more .bfq read names are longer than 2047 characters"); + cerr << "One or more .bfq read names are longer than 2047 characters" << endl; + throw 1; } // Read name gzread(fp, name, sizeof(char) * len); @@ -39,8 +39,8 @@ static bool ma_load_1read(gzFile fp, TStr& ret) { // Read sequence length if(gzread(fp, &len, sizeof(int)) != sizeof(int)) return false; if(len > 2048) { - throw std::runtime_error( - "One or more .bfq read sequences are longer than 2048 bases"); + cerr << "One or more .bfq read sequences are longer than 2048 bases" << endl; + throw 1; } seqan::reserve(ret, len, seqan::Exact()); gzread(fp, seq, sizeof(char) * len); diff --git a/pat.cpp b/pat.cpp index 49cd734..e57138a 100644 --- a/pat.cpp +++ b/pat.cpp @@ -13,25 +13,25 @@ void wrongQualityFormat(const String& read_name) { << "If this is a FASTQ file with integer (non-ASCII-encoded) qualities, please" << endl << "re-run Bowtie with the --integer-quals option. If this is a FASTQ file with" << endl << "alternate basecall information, please re-run Bowtie with the --fuzzy option." << endl; - throw std::runtime_error(""); + throw 1; } void tooFewQualities(const String& read_name) { cerr << "Too few quality values for read: " << read_name << endl << "\tare you sure this is a FASTQ-int file?" << endl; - throw std::runtime_error(""); + throw 1; } void tooManyQualities(const String& read_name) { cerr << "Reads file contained a pattern with more than 1024 quality values." << endl << "Please truncate reads and quality values and and re-run Bowtie" << endl; - throw std::runtime_error(""); + throw 1; } void tooManySeqChars(const String& read_name) { cerr << "Reads file contained a pattern with more than 1024 sequence characters." << endl << "Please truncate reads and quality values and and re-run Bowtie" << endl; - throw std::runtime_error(""); + throw 1; } /** diff --git a/pat.h b/pat.h index cf5e7c1..cc15e3d 100644 --- a/pat.h +++ b/pat.h @@ -356,7 +356,7 @@ class PatternSource { out_.open(dumpfile_, ios_base::out); if(!out_.good()) { cerr << "Could not open pattern dump file \"" << dumpfile_ << "\" for writing" << endl; - throw std::runtime_error(""); + throw 1; } } MUTEX_INIT(lock_); @@ -1060,7 +1060,7 @@ class RandomPatternSource : public PatternSource { { if(length_ > 1024) { cerr << "Read length for RandomPatternSource may not exceed 1024; got " << length_ << endl; - throw std::runtime_error(""); + throw 1; } rand_.init(seed_); } @@ -1155,7 +1155,7 @@ class RandomPatternSourcePerThread : public PatternSourcePerThread { patid_ = thread_; if(length_ > 1024) { cerr << "Read length for RandomPatternSourcePerThread may not exceed 1024; got " << length_ << endl; - throw std::runtime_error(""); + throw 1; } rand_.init(thread_); } @@ -1595,7 +1595,7 @@ class BufferedFilePatternSource : public TrimmingPatternSource { filebuf_.newFile(in); return; } - throw std::runtime_error(""); + throw 1; } vector infiles_; /// filenames for read files vector errs_; /// whether we've already printed an error for each file @@ -1673,7 +1673,7 @@ class FastaPatternSource : public BufferedFilePatternSource { } if(c != '>') { cerr << "Error: reads file does not look like a FASTA file" << endl; - throw std::runtime_error(""); + throw 1; } assert(c == '>' || c == '#'); first_ = false; @@ -1711,7 +1711,7 @@ class FastaPatternSource : public BufferedFilePatternSource { if(dstLen + 1 > 1024) { cerr << "Input file contained a pattern more than 1024 characters long. Please truncate" << endl << "reads and re-run Bowtie" << endl; - throw std::runtime_error(""); + throw 1; } r.patBufFw [dstLen] = charToDna5[c]; r.qualBuf[dstLen] = 'I'; @@ -1748,7 +1748,7 @@ class FastaPatternSource : public BufferedFilePatternSource { virtual void readPair(ReadBuf& ra, ReadBuf& rb, uint32_t& patid) { // (For now, we shouldn't ever be here) cerr << "In FastaPatternSource.readPair()" << endl; - throw std::runtime_error(""); + throw 1; read(ra, patid); readCnt_--; read(rb, patid); @@ -2027,7 +2027,7 @@ class TabbedPatternSource : public BufferedFilePatternSource { if(dstLen + 1 > 1024) { cerr << "Input file contained a pattern more than 1024 characters long. Please truncate" << endl << "reads and re-run Bowtie" << endl; - throw std::runtime_error(""); + throw 1; } r.patBufFw[dstLen] = charToDna5[c]; dstLen++; @@ -2229,7 +2229,7 @@ class FastaContinuousPatternSource : public BufferedFilePatternSource { // from a continuous input. virtual void readPair(ReadBuf& ra, ReadBuf& rb, uint32_t& patid) { cerr << "In FastaContinuousPatternSource.readPair()" << endl; - throw std::runtime_error(""); + throw 1; } /** @@ -2371,7 +2371,7 @@ class FastqPatternSource : public BufferedFilePatternSource { } if(c != '@') { cerr << "Error: reads file does not look like a FASTQ file" << endl; - throw std::runtime_error(""); + throw 1; } assert_eq('@', c); first_ = false; @@ -2405,7 +2405,7 @@ class FastqPatternSource : public BufferedFilePatternSource { _setLength(r.name, nameLen); cerr << "FASTQ read name is too long; read names must be " << (bufSz-2) << " characters or fewer." << endl; cerr << "Beginning of bad read name: " << r.name << endl; - throw std::runtime_error(""); + throw 1; } } _setBegin(r.name, r.nameBuf); @@ -2440,7 +2440,7 @@ class FastqPatternSource : public BufferedFilePatternSource { charsRead = 0; if(altBufIdx >= 3) { cerr << "At most 3 alternate sequence strings permitted; offending read: " << r.name << endl; - throw std::runtime_error(""); + throw 1; } // Move on to the next alternate-sequence buffer sbuf = r.altPatBufFw[altBufIdx++]; @@ -2505,7 +2505,7 @@ class FastqPatternSource : public BufferedFilePatternSource { if((*qualsReadCur) == 0) continue; if(altBufIdx >= 3) { cerr << "At most 3 alternate quality strings permitted; offending read: " << r.name << endl; - throw std::runtime_error(""); + throw 1; } qbuf = r.altQualBuf[altBufIdx++]; qualsReadCur = &qualsRead[altBufIdx]; @@ -2602,7 +2602,7 @@ class FastqPatternSource : public BufferedFilePatternSource { virtual void readPair(ReadBuf& ra, ReadBuf& rb, uint32_t& patid) { // (For now, we shouldn't ever be here) cerr << "In FastqPatternSource.readPair()" << endl; - throw std::runtime_error(""); + throw 1; read(ra, patid); readCnt_--; read(rb, patid); @@ -2670,7 +2670,7 @@ class RawPatternSource : public BufferedFilePatternSource { if(c == '@') { cerr << "Reads file looks like a FASTQ file; please use -q" << endl; } - throw std::runtime_error(""); + throw 1; } first_ = false; } @@ -2715,7 +2715,7 @@ class RawPatternSource : public BufferedFilePatternSource { virtual void readPair(ReadBuf& ra, ReadBuf& rb, uint32_t& patid) { // (For now, we shouldn't ever be here) cerr << "In RawPatternSource.readPair()" << endl; - throw std::runtime_error(""); + throw 1; read(ra, patid); readCnt_--; read(rb, patid); @@ -2793,10 +2793,7 @@ class ChainPatternSource : public BufferedFilePatternSource { virtual void readPair(ReadBuf& ra, ReadBuf& rb, uint32_t& patid) { // (For now, we shouldn't ever be here) cerr << "In ChainPatternSource.readPair()" << endl; - throw std::runtime_error(""); - read(ra, patid); - readCnt_--; - read(rb, patid); + throw 1; } }; diff --git a/pool.h b/pool.h index e9854c8..cd0f168 100644 --- a/pool.h +++ b/pool.h @@ -39,7 +39,7 @@ class ChunkPool { std::cerr << "Error: Could not allocate ChunkPool of " << totSz << " bytes" << std::endl; exhausted(); - throw std::runtime_error(""); // Exit if we haven't already + throw 1; // Exit if we haven't already } } @@ -148,7 +148,7 @@ class ChunkPool { } if(exhaustCrash_) { std::cerr << "Please try specifying a larger --chunkmbs (default is 32)" << std::endl; - throw std::runtime_error(""); + throw 1; } lastSkippedRead_ = patid; } diff --git a/qual.h b/qual.h index 7930bf8..832c70a 100644 --- a/qual.h +++ b/qual.h @@ -85,7 +85,7 @@ inline static char charToPhred33(char c, bool solQuals, bool phred64Quals) { if(c == ' ') { cerr << "Saw a space but expected an ASCII-encoded quality value." << endl << "Are quality values formatted as integers? If so, try --integer-quals." << endl; - throw std::runtime_error(""); + throw 1; } if (solQuals) { // Convert solexa-scaled chars to phred @@ -96,7 +96,7 @@ inline static char charToPhred33(char c, bool solQuals, bool phred64Quals) { << ((int)c) << " but expected 64-based Solexa qual (converts to " << (int)cc << ")." << endl << "Try not specifying --solexa-quals." << endl; - throw std::runtime_error(""); + throw 1; } c = cc; } @@ -106,7 +106,7 @@ inline static char charToPhred33(char c, bool solQuals, bool phred64Quals) { << ((int)c) << " but expected 64-based Phred qual." << endl << "Try not specifying --solexa1.3-quals/--phred64-quals." << endl; - throw std::runtime_error(""); + throw 1; } // Convert to 33-based phred c -= (64-33); @@ -117,7 +117,7 @@ inline static char charToPhred33(char c, bool solQuals, bool phred64Quals) { cerr << "Saw ASCII character " << ((int)c) << " but expected 33-based Phred qual." << endl; - throw std::runtime_error(""); + throw 1; } } return c; @@ -141,7 +141,7 @@ inline static char intToPhred33(int iQ, bool solQuals) { } if (pQ < 33) { cerr << "Saw negative Phred quality " << ((int)pQ-33) << "." << endl; - throw std::runtime_error(""); + throw 1; } assert_geq(pQ, 0); return (int)pQ; diff --git a/range_cache.h b/range_cache.h index 1ed590d..447ae38 100644 --- a/range_cache.h +++ b/range_cache.h @@ -43,7 +43,7 @@ class RangeCacheMemPool { } catch(std::bad_alloc& e) { cerr << "Allocation error allocating " << lim << " words of range-cache memory" << endl; - throw std::runtime_error(""); + throw 1; } assert(buf_ != NULL); // Fill with 1s to signal that these elements are diff --git a/range_source.h b/range_source.h index ddf7bf6..6a45498 100644 --- a/range_source.h +++ b/range_source.h @@ -1917,7 +1917,7 @@ class StubRangeSourceDriver : public RangeSourceDriver { virtual void advanceImpl(int until) { } /// Return the last valid range found - virtual Range& range() { throw std::runtime_error(""); } + virtual Range& range() { throw 1; } /** * Return whether we're generating ranges for the first or the diff --git a/ref_aligner.h b/ref_aligner.h index b787af5..2161e3e 100644 --- a/ref_aligner.h +++ b/ref_aligner.h @@ -138,7 +138,7 @@ class RefAligner { if(refbuf_ == NULL) throw std::bad_alloc(); } catch(std::bad_alloc& e) { cerr << "Error: Could not allocate reference-space alignment buffer of " << newsz << "B" << endl; - throw std::runtime_error(""); + throw 1; } refbufSz_ = newsz; freeRefbuf_ = true; diff --git a/ref_read.cpp b/ref_read.cpp index 1e96f52..57c9eae 100644 --- a/ref_read.cpp +++ b/ref_read.cpp @@ -179,7 +179,7 @@ size_t fastaRefReadSizes(vector& in, cerr << "Error: Reference sequence has more than 2^32-1 characters! Please divide the" << endl << "reference into batches or chunks of about 3.6 billion characters or less each" << endl << "and index each independently." << endl; - throw std::runtime_error(""); + throw 1; } tot += rec.len; first = false; diff --git a/ref_read.h b/ref_read.h index 4e3d7ed..e1d0862 100644 --- a/ref_read.h +++ b/ref_read.h @@ -43,12 +43,12 @@ struct RefRecord { assert(in != NULL); if(!fread(&off, 4, 1, in)) { cerr << "Error reading RefRecord offset from FILE" << endl; - throw std::runtime_error(""); + throw 1; } if(swap) off = endianSwapU32(off); if(!fread(&len, 4, 1, in)) { cerr << "Error reading RefRecord offset from FILE" << endl; - throw std::runtime_error(""); + throw 1; } if(swap) len = endianSwapU32(len); first = fgetc(in) ? true : false; @@ -60,7 +60,7 @@ struct RefRecord { char c; if(!read(in, &c, 1)) { cerr << "Error reading RefRecord 'first' flag" << endl; - throw std::runtime_error(""); + throw 1; } first = (c ? true : false); } @@ -139,7 +139,7 @@ static RefRecord fastaRefReadAppend(FileBuf& in, c = skipWhitespace(in); if(c != '>') { cerr << "Reference file does not seem to be a FASTA file" << endl; - throw std::runtime_error(""); + throw 1; } lastc = c; } diff --git a/reference.h b/reference.h index 026728d..37c9eb9 100644 --- a/reference.h +++ b/reference.h @@ -77,14 +77,14 @@ class BitPairReference { if (stat(s4.c_str(), &sbuf) == -1) { perror("stat"); cerr << "Error: Could not stat index file " << s4.c_str() << " prior to memory-mapping" << endl; - throw std::runtime_error(""); + throw 1; } mmFile = (char*)mmap((void *)0, sbuf.st_size, PROT_READ, MAP_SHARED, f4, 0); if(mmFile == (void *)(-1) || mmFile == NULL) { perror("mmap"); cerr << "Error: Could not memory-map the index file " << s4.c_str() << endl; - throw std::runtime_error(""); + throw 1; } if(mmSweep) { int sum = 0; @@ -121,7 +121,7 @@ class BitPairReference { if(one != 1) { if(useMm_) { cerr << "Error: Can't use memory-mapped files when the index is the opposite endianness" << endl; - throw std::runtime_error(""); + throw 1; } assert_eq(0x1000000, one); swap = true; // have to endian swap U32s @@ -132,7 +132,7 @@ class BitPairReference { sz = readU32(f3, swap); if(sz == 0) { cerr << "Error: number of reference records is 0 in " << s3 << endl; - throw std::runtime_error(""); + throw 1; } // Read records @@ -159,7 +159,7 @@ class BitPairReference { nrefs_++; } else if(i == 0) { cerr << "First record in reference index file was not marked as 'first'" << endl; - throw std::runtime_error(""); + throw 1; } cumsz += recs_.back().len; cumlen += recs_.back().off; @@ -192,7 +192,7 @@ class BitPairReference { size_t ret = fread(sanityBuf_, 1, cumsz >> 2, ftmp); if(ret != (cumsz >> 2)) { cerr << "Only read " << ret << " bytes (out of " << (cumsz >> 2) << ") from reference index file " << s4 << endl; - throw std::runtime_error(""); + throw 1; } fclose(ftmp); for(size_t i = 0; i < (cumsz >> 2); i++) { @@ -201,7 +201,7 @@ class BitPairReference { } #else cerr << "Shouldn't be at " << __FILE__ << ":" << __LINE__ << " without BOWTIE_MM defined" << endl; - throw std::runtime_error(""); + throw 1; #endif } else { bool shmemLeader = true; @@ -213,7 +213,7 @@ class BitPairReference { } catch(std::bad_alloc& e) { cerr << "Error: Ran out of memory allocating space for the bitpacked reference. Please" << endl << "re-run on a computer with more memory." << endl; - throw std::runtime_error(""); + throw 1; } } else { shmemLeader = ALLOC_SHARED_U8( @@ -236,7 +236,7 @@ class BitPairReference { // Didn't read all of it? if(ret != (cumsz >> 2)) { cerr << "Only read " << ret << " bytes (out of " << (cumsz >> 2) << ") from reference index file " << s4 << endl; - throw std::runtime_error(""); + throw 1; } // Make sure there's no more char c; diff --git a/refmap.cpp b/refmap.cpp index b254e00..025d563 100644 --- a/refmap.cpp +++ b/refmap.cpp @@ -21,7 +21,7 @@ void ReferenceMap::map(U32Pair& h) const { cerr << "Could not find a reference-map entry for reference " << h.first << " in map file \"" << fname_ << "\"" << endl; - throw std::runtime_error(""); + throw 1; } h.second += map_[h.first].second; h.first = map_[h.first].first; @@ -34,7 +34,7 @@ void ReferenceMap::parse() { ifstream in(fname_); if(!in.good() || !in.is_open()) { cerr << "Could not open reference map file " << fname_ << endl; - throw std::runtime_error(""); + throw 1; } int c; while((c = in.peek()) != EOF) { @@ -60,8 +60,5 @@ void ReferenceMap::parse() { while(isspace(in.peek())) in.get(); } assert_eq(EOF, c); - if(map_.empty()) { - throw std::runtime_error(""); - } in.close(); } diff --git a/sam.cpp b/sam.cpp index 6696bfa..98457a3 100644 --- a/sam.cpp +++ b/sam.cpp @@ -29,6 +29,11 @@ void SAMHitSink::appendAligned(ostream& ss, ss << h.patName << "\t"; // FLAG int flags = 0; + if(h.mate == 1) { + flags |= SAM_FLAG_PAIRED | SAM_FLAG_SECOND_IN_PAIR; + } else if(h.mate == 2) { + flags |= SAM_FLAG_PAIRED | SAM_FLAG_FIRST_IN_PAIR; + } if(!h.fw) flags |= SAM_FLAG_QUERY_STRAND; ss << flags << "\t"; // RNAME diff --git a/search_1mm_phase1.c b/search_1mm_phase1.c index f6ac90a..8614947 100644 --- a/search_1mm_phase1.c +++ b/search_1mm_phase1.c @@ -11,7 +11,7 @@ if(plen < 2) { cerr << "Error: Reads must be at least 2 characters long in 1-mismatch mode" << endl; - throw std::runtime_error(""); + throw 1; } if(!nofw) { diff --git a/search_23mm_phase1.c b/search_23mm_phase1.c index 9288555..494d920 100644 --- a/search_23mm_phase1.c +++ b/search_23mm_phase1.c @@ -12,11 +12,11 @@ if(plen < 3 && two) { cerr << "Error: Read (" << name << ") is less than 3 characters long" << endl; - throw std::runtime_error(""); + throw 1; } else if(plen < 4) { cerr << "Error: Read (" << name << ") is less than 4 characters long" << endl; - throw std::runtime_error(""); + throw 1; } if(!nofw) { // Do an exact-match search on the forward pattern, just in diff --git a/sequence_io.h b/sequence_io.h index 255f0a1..09b4366 100644 --- a/sequence_io.h +++ b/sequence_io.h @@ -30,11 +30,13 @@ static void readSequenceFile(const std::string& infile, if(baseCutoff <= 0) return; FILE *in = fopen(infile.c_str(), "r"); if(in == NULL) { - throw runtime_error("Could not open sequence file"); + cerr << "Could not open sequence file" << endl; + throw 1; } // Associate large input buffer with FILE *in if(setvbuf(in, buf, _IOFBF, 256 * 1024) != 0) { - throw runtime_error("Could not create input buffer for sequence file"); + cerr << "Could not create input buffer for sequence file" << endl; + throw 1; } // Read entries using SeqAn int cnt = 0; diff --git a/shmem.h b/shmem.h index c991696..5e5145d 100644 --- a/shmem.h +++ b/shmem.h @@ -70,7 +70,7 @@ bool allocSharedMem(std::string fname, cerr << "shmctl returned " << ret << " for IPC_RMID, errno is " << errno << ", shmid is " << shmid << endl; - throw std::runtime_error(""); + throw 1; } else { cerr << "Deleted shared mem chunk with shmid " << shmid << endl; } @@ -82,22 +82,22 @@ bool allocSharedMem(std::string fname, } else { cerr << "shmget returned " << shmid << " for and errno is " << errno << endl; } - throw std::runtime_error(""); + throw 1; } ptr = (T*)shmat(shmid, 0, 0); if(ptr == (void*)-1) { cerr << "Failed to attach " << memName << " to shared memory with shmat()." << endl; - throw std::runtime_error(""); + throw 1; } if(ptr == NULL) { cerr << memName << " pointer returned by shmat() was NULL." << endl; - throw std::runtime_error(""); + throw 1; } // Did I create it, or did I just attach to one created by // another process? if((ret = shmctl(shmid, IPC_STAT, &ds)) < 0) { cerr << "shmctl returned " << ret << " for IPC_STAT and errno is " << errno << endl; - throw std::runtime_error(""); + throw 1; } if(ds.shm_segsz != shmemLen) { cerr << "Warning: shared-memory chunk's segment size (" << ds.shm_segsz @@ -105,7 +105,7 @@ bool allocSharedMem(std::string fname, << "Deleteing old shared memory block and trying again." << endl; if((ret = shmctl(shmid, IPC_RMID, &ds)) < 0) { cerr << "shmctl returned " << ret << " for IPC_RMID and errno is " << errno << endl; - throw std::runtime_error(""); + throw 1; } } else { break;