catch a number of uncaught exceptions

This commit is contained in:
Dennis Luxen 2014-10-15 10:23:48 +02:00
parent a9d99cbe54
commit 549ba65861
5 changed files with 54 additions and 46 deletions

View File

@ -44,14 +44,14 @@ using QueryGraph = StaticGraph<EdgeData>;
int main(int argc, char *argv[])
{
LogPolicy::GetInstance().Unmute();
if (argc != 2)
{
SimpleLogger().Write(logWARNING) << "usage: " << argv[0] << " <file.hsgr>";
return 1;
}
try
{
if (argc != 2)
{
SimpleLogger().Write(logWARNING) << "usage: " << argv[0] << " <file.hsgr>";
return 1;
}
boost::filesystem::path hsgr_path(argv[1]);
std::vector<QueryGraph::NodeArrayEntry> node_list;

View File

@ -44,16 +44,16 @@ std::vector<NodeID> trafficlight_ID_list;
int main(int argc, char *argv[])
{
// enable logging
LogPolicy::GetInstance().Unmute();
if (argc < 3)
{
SimpleLogger().Write(logWARNING) << "usage:\n" << argv[0] << " <osrm> <osrm.restrictions>";
return -1;
}
try
{
// enable logging
if (argc < 3)
{
SimpleLogger().Write(logWARNING) << "usage:\n" << argv[0] << " <osrm> <osrm.restrictions>";
return -1;
}
SimpleLogger().Write() << "Using restrictions from file: " << argv[2];
std::ifstream restriction_ifstream(argv[2], std::ios::binary);
const FingerPrint fingerprint_orig;

View File

@ -71,31 +71,31 @@ void RunStatistics(std::vector<double> &timings_vector, Statistics &stats)
int main(int argc, char *argv[])
{
LogPolicy::GetInstance().Unmute();
SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION << ", "
<< "compiled at " << __DATE__ << ", " __TIME__;
#ifdef __FreeBSD__
SimpleLogger().Write() << "Not supported on FreeBSD";
return 0;
#endif
#ifdef WIN32
SimpleLogger().Write() << "Not supported on Windows";
return 0;
#else
if (1 == argc)
{
SimpleLogger().Write(logWARNING) << "usage: " << argv[0] << " /path/on/device";
return -1;
}
boost::filesystem::path test_path = boost::filesystem::path(argv[1]);
test_path /= "osrm.tst";
SimpleLogger().Write(logDEBUG) << "temporary file: " << test_path.string();
boost::filesystem::path test_path;
try
{
SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION << ", "
<< "compiled at " << __DATE__ << ", " __TIME__;
#ifdef __FreeBSD__
SimpleLogger().Write() << "Not supported on FreeBSD";
return 0;
#endif
#ifdef WIN32
SimpleLogger().Write() << "Not supported on Windows";
return 0;
#else
if (1 == argc)
{
SimpleLogger().Write(logWARNING) << "usage: " << argv[0] << " /path/on/device";
return -1;
}
test_path = boost::filesystem::path(argv[1]);
test_path /= "osrm.tst";
SimpleLogger().Write(logDEBUG) << "temporary file: " << test_path.string();
// create files for testing
if (2 == argc)
{

View File

@ -95,17 +95,16 @@ int main(const int argc, const char *argv[])
LogPolicy::GetInstance().Unmute();
SharedBarriers barrier;
#ifdef __linux__
// try to disable swapping on Linux
const bool lock_flags = MCL_CURRENT | MCL_FUTURE;
if (-1 == mlockall(lock_flags))
{
SimpleLogger().Write(logWARNING) << "Process " << argv[0] << " could not request RAM lock";
}
#endif
try
{
#ifdef __linux__
// try to disable swapping on Linux
const bool lock_flags = MCL_CURRENT | MCL_FUTURE;
if (-1 == mlockall(lock_flags))
{
SimpleLogger().Write(logWARNING) << "Process " << argv[0] << " could not request RAM lock";
}
#endif
try
{
boost::interprocess::scoped_lock<boost::interprocess::named_mutex> pending_lock(

View File

@ -26,8 +26,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "Extractor/Extractor.h"
#include "Util/simple_logger.hpp"
int main (int argc, char *argv[])
{
return Extractor().Run(argc, argv);
try
{
return Extractor().Run(argc, argv);
}
catch (const std::exception &e)
{
SimpleLogger().Write(logWARNING) << "[exception] " << e.what();
}
}