[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IMP-dev] writing .cpp applications for IMP



The new Mac OS runtime (as of 10.7) doesn't print out the error messages for uncaught exceptions and instead just gives a very cryptic and unhelpful message about an exception being thrown, with no more details. This unhelpful behavior can include uncaught exceptions when program_options doesn't find what it wants. As a result, it is a good idea to make sure the code in your .cpp mains in enclosed in a try/catch block that prints out the message. Something like

int main(int argc, char **argv) {
  try {
	do stuff...
      return 0;
    }
  } catch (const IMP::Exception &e) {
    std::cerr << "Error: " << e.what() << std::endl;
    return 1;
  } catch (const std::exception &e) {
    std::cerr << "Error: " << e.what() << std::endl;
    return 1;
  }