From 34735b8aad06098d09d3fb907137697799a281e4 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 5 Jul 2013 22:36:51 +0200 Subject: [PATCH] throw an exception when server.ini is missing --- Library/OSRM.cpp | 4 ++++ Library/OSRM.h | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Library/OSRM.cpp b/Library/OSRM.cpp index 57603953d..4a472c626 100644 --- a/Library/OSRM.cpp +++ b/Library/OSRM.cpp @@ -21,6 +21,10 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "OSRM.h" OSRM::OSRM(const char * server_ini_path) { + if( !testDataFile(server_ini_path) ){ + throw OSRMException("server.ini not found"); + } + BaseConfiguration serverConfig(server_ini_path); objects = new QueryObjectsStorage( serverConfig.GetParameter("hsgrData"), diff --git a/Library/OSRM.h b/Library/OSRM.h index ec5f5d98f..9a4c601d5 100644 --- a/Library/OSRM.h +++ b/Library/OSRM.h @@ -31,15 +31,26 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Plugins/ViaRoutePlugin.h" #include "../Plugins/RouteParameters.h" #include "../Util/BaseConfiguration.h" +#include "../Util/InputFileUtil.h" #include "../Server/BasicDatastructures.h" - #include #include #include +#include #include +class OSRMException: public std::exception { +public: + OSRMException(const char * message) : message(message) {} +private: + virtual const char* what() const throw() { + return message; + } + const char * message; +}; + class OSRM : boost::noncopyable { typedef boost::unordered_map PluginMap; QueryObjectsStorage * objects;