@@ -252,7 +252,7 @@ namespace mtconnect {
252252 catch (std::runtime_error &e)
253253 {
254254 LOG (fatal) << " Cannot start server: " << e.what ();
255- std::exit ( 1 );
255+ throw FatalException (e. what () );
256256 }
257257
258258 m_started = true ;
@@ -436,14 +436,14 @@ namespace mtconnect {
436436 LOG (fatal) << " Error loading xml configuration: " + deviceFile;
437437 LOG (fatal) << " Error detail: " << e.what ();
438438 cerr << e.what () << endl;
439- throw e ;
439+ throw FatalException (e. what ()) ;
440440 }
441441 catch (exception &f)
442442 {
443443 LOG (fatal) << " Error loading xml configuration: " + deviceFile;
444444 LOG (fatal) << " Error detail: " << f.what ();
445445 cerr << f.what () << endl;
446- throw f ;
446+ throw FatalException (f. what ()) ;
447447 }
448448 }
449449
@@ -525,6 +525,10 @@ namespace mtconnect {
525525 if (changed)
526526 loadCachedProbe ();
527527 }
528+ catch (FatalException &e)
529+ {
530+ throw e;
531+ }
528532 catch (runtime_error &e)
529533 {
530534 for (auto device : devices)
@@ -832,7 +836,7 @@ namespace mtconnect {
832836 {
833837 for (auto &e : errors)
834838 LOG (fatal) << " Error creating the agent device: " << e->what ();
835- throw EntityError (" Cannot create AgentDevice" );
839+ throw FatalException (" Cannot create AgentDevice" );
836840 }
837841 addDevice (m_agentDevice);
838842 }
@@ -870,14 +874,14 @@ namespace mtconnect {
870874 LOG (fatal) << " Error loading xml configuration: " + configXmlPath;
871875 LOG (fatal) << " Error detail: " << e.what ();
872876 cerr << e.what () << endl;
873- throw e ;
877+ throw FatalException (e. what ()) ;
874878 }
875879 catch (exception &f)
876880 {
877881 LOG (fatal) << " Error loading xml configuration: " + configXmlPath;
878882 LOG (fatal) << " Error detail: " << f.what ();
879883 cerr << f.what () << endl;
880- throw f ;
884+ throw FatalException (f. what ()) ;
881885 }
882886
883887 return {};
@@ -976,9 +980,13 @@ namespace mtconnect {
976980 auto di = m_dataItemMap[d->getId ()].lock ();
977981 if (di && di != d)
978982 {
979- LOG (fatal) << " Duplicate DataItem id " << d->getId ()
980- << " for device: " << *device->getComponentName ();
981- std::exit (1 );
983+ stringstream msg;
984+
985+ msg << " Duplicate DataItem id " << d->getId ()
986+ << " for device: " << *device->getComponentName ()
987+ << " . Try using configuration option CreateUniqueIds to resolve." ;
988+ LOG (fatal) << msg.str ();
989+ throw FatalException (msg.str ());
982990 }
983991 }
984992 else
@@ -1008,9 +1016,10 @@ namespace mtconnect {
10081016 if (old != idx.end ())
10091017 {
10101018 // Update existing device
1011- LOG (fatal) << " Device " << *device->getUuid () << " already exists. "
1012- << " Update not supported yet" ;
1013- std::exit (1 );
1019+ stringstream msg;
1020+ msg << " Device " << *device->getUuid () << " already exists. "
1021+ << " Update not supported yet" ;
1022+ throw msg;
10141023 }
10151024 else
10161025 {
0 commit comments