diff --git a/MQTTSNGateway/src/MQTTSNGWProcess.cpp b/MQTTSNGateway/src/MQTTSNGWProcess.cpp index 88ba292..2abe3a5 100644 --- a/MQTTSNGateway/src/MQTTSNGWProcess.cpp +++ b/MQTTSNGateway/src/MQTTSNGWProcess.cpp @@ -162,8 +162,7 @@ int Process::getParam(const char* parameter, char* value) if ((fp = fopen(configPath.c_str(), "r")) == NULL) { - WRITELOG("No config file:[%s]\n", configPath.c_str()); - return -1; + throw Exception("No config file:[" + configPath + "]\n"); } while (true) diff --git a/MQTTSNGateway/src/mainGateway.cpp b/MQTTSNGateway/src/mainGateway.cpp index 6fcbbc4..e196d96 100644 --- a/MQTTSNGateway/src/mainGateway.cpp +++ b/MQTTSNGateway/src/mainGateway.cpp @@ -1,5 +1,5 @@ /************************************************************************************** - * Copyright (c) 2016, Tomoaki Yamaguchi + * Copyright (c) 2016, 2020 Tomoaki Yamaguchi and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -34,7 +34,12 @@ BrokerSendTask task5(&gateway); int main(int argc, char** argv) { - gateway.initialize(argc, argv); - gateway.run(); + try { + gateway.initialize(argc, argv); + gateway.run(); + } catch (const std::exception &ex) { + WRITELOG("\nEclipse Paho MQTT-SN Gateway exception: %s\n", ex.what()); + WRITELOG("MQTT-SNGateway [-f Config file name]\n"); + } return 0; }