use exceptions instead of hard abort

This commit is contained in:
Dennis Luxen
2013-08-05 17:28:57 +02:00
parent ec7d3a9885
commit 54302a53e1
23 changed files with 248 additions and 193 deletions
@@ -33,7 +33,9 @@ QueryObjectsStorage::QueryObjectsStorage(
) {
INFO("loading graph data");
std::ifstream hsgrInStream(hsgrPath.c_str(), std::ios::binary);
if(!hsgrInStream) { ERR(hsgrPath << " not found"); }
if(!hsgrInStream) {
throw OSRMException("hsgr not found");
}
//Deserialize road network graph
std::vector< QueryGraph::_StrNode> nodeList;
std::vector< QueryGraph::_StrEdge> edgeList;
@@ -79,7 +81,9 @@ QueryObjectsStorage::QueryObjectsStorage(
//deserialize street name list
INFO("Loading names index");
std::ifstream namesInStream(namesPath.c_str(), std::ios::binary);
if(!namesInStream) { ERR(namesPath << " not found"); }
if(!namesInStream) {
throw OSRMException("names file not found");
}
unsigned size(0);
namesInStream.read((char *)&size, sizeof(unsigned));
@@ -25,6 +25,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include<vector>
#include<string>
#include "../../Util/OSRMException.h"
#include "../../DataStructures/NodeInformationHelpDesk.h"
#include "../../DataStructures/QueryEdge.h"
#include "../../DataStructures/StaticGraph.h"
+10 -8
View File
@@ -30,6 +30,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "../Util/BaseConfiguration.h"
#include "../Util/InputFileUtil.h"
#include "../Util/OpenMPWrapper.h"
#include "../Util/OSRMException.h"
#include "../Util/StringUtil.h"
#include "../typedefs.h"
@@ -40,31 +41,32 @@ struct ServerFactory {
static Server * CreateServer(BaseConfiguration& serverConfig) {
if(!testDataFile(serverConfig.GetParameter("nodesData"))) {
ERR("nodes file not found");
throw OSRMException("nodes file not found");
}
if(!testDataFile(serverConfig.GetParameter("hsgrData"))) {
ERR("hsgr file not found");
throw OSRMException("hsgr file not found");
}
if(!testDataFile(serverConfig.GetParameter("namesData"))) {
ERR("names file not found");
throw OSRMException("names file not found");
}
if(!testDataFile(serverConfig.GetParameter("ramIndex"))) {
ERR("ram index file not found");
throw OSRMException("ram index file not found");
}
if(!testDataFile(serverConfig.GetParameter("fileIndex"))) {
ERR("file index file not found");
throw OSRMException("file index file not found");
}
int threads = omp_get_num_procs();
if(serverConfig.GetParameter("IP") == "")
if(serverConfig.GetParameter("IP") == "") {
serverConfig.SetParameter("IP", "0.0.0.0");
if(serverConfig.GetParameter("Port") == "")
}
if(serverConfig.GetParameter("Port") == "") {
serverConfig.SetParameter("Port", "5000");
}
if(stringToInt(serverConfig.GetParameter("Threads")) != 0 && stringToInt(serverConfig.GetParameter("Threads")) <= threads)
threads = stringToInt( serverConfig.GetParameter("Threads") );