From 4aa43e9293454ea0855a8ee16e4eb46246695581 Mon Sep 17 00:00:00 2001 From: Michael Hopcroft Date: Wed, 22 Feb 2017 18:50:49 -0800 Subject: [PATCH] Fix crash in TheBard. --- tools/BitFunnel/src/TheBard.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tools/BitFunnel/src/TheBard.cpp b/tools/BitFunnel/src/TheBard.cpp index cb9c87d4..4e9a28e1 100644 --- a/tools/BitFunnel/src/TheBard.cpp +++ b/tools/BitFunnel/src/TheBard.cpp @@ -27,8 +27,10 @@ #include "BitFunnel/Configuration/Factories.h" #include "BitFunnel/Configuration/IFileSystem.h" #include "BitFunnel/Data/Sonnets.h" +#include "BitFunnel/Exceptions.h" #include "BitFunnelTool.h" #include "CmdLineParser/CmdLineParser.h" +#include "LoggerInterfaces/Check.h" namespace BitFunnel @@ -120,16 +122,20 @@ namespace BitFunnel std::vector argv = { "BitFunnel", "termtable", - "config" + "config", + "0.1", + "PrivateSharedRank0ToN" }; std::stringstream ignore; std::ostream& out = (verbose) ? std::cout : ignore; - tool.Main(std::cin, - out, - static_cast(argv.size()), - argv.data()); + auto result = tool.Main(std::cin, + out, + static_cast(argv.size()), + argv.data()); + + CHECK_EQ(result, 0) << "TermTableBuilder failed."; std::cout << "Index is now configured." @@ -183,7 +189,21 @@ int main(int argc, char** argv) if (parser.TryParse(std::cout, argc, argv)) { - BitFunnel::Run(verbose.IsActivated()); + try + { + BitFunnel::Run(verbose.IsActivated()); + } + catch (BitFunnel::RecoverableError e) + { + std::cout << "Error: " << e.what() << std::endl; + } + catch (...) + { + // TODO: Do we really want to catch all exceptions here? + // Seems we want to at least print out the error message for BitFunnel exceptions. + + std::cout << "Unexpected error." << std::endl; + } } return returnCode;