Mercurial > hg > orthanc
diff OrthancServer/main.cpp @ 1675:131136aeeaa7 db-changes
improved exception handling in the main program
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Oct 2015 13:57:54 +0200 |
parents | 4c5a85c3ff43 |
children | bc34c69b594a |
line wrap: on
line diff
--- a/OrthancServer/main.cpp Fri Oct 02 13:31:39 2015 +0200 +++ b/OrthancServer/main.cpp Fri Oct 02 13:57:54 2015 +0200 @@ -572,13 +572,28 @@ dicomServer.Start(); LOG(WARNING) << "DICOM server listening on port: " << dicomServer.GetPortNumber(); - bool restart = StartHttpServer(context, restApi, plugins); + bool restart; + ErrorCode error = ErrorCode_Success; + + try + { + restart = StartHttpServer(context, restApi, plugins); + } + catch (OrthancException& e) + { + error = e.GetErrorCode(); + } dicomServer.Stop(); LOG(WARNING) << " DICOM server has stopped"; serverFactory.Done(); + if (error != ErrorCode_Success) + { + throw OrthancException(error); + } + return restart; } @@ -694,7 +709,18 @@ } #endif - bool restart = ConfigureHttpHandler(context, plugins); + bool restart; + ErrorCode error = ErrorCode_Success; + + try + { + restart = ConfigureHttpHandler(context, plugins); + } + catch (OrthancException& e) + { + error = e.GetErrorCode(); + } + context.Stop(); #if ORTHANC_PLUGINS_ENABLED == 1 @@ -704,6 +730,11 @@ } #endif + if (error != ErrorCode_Success) + { + throw OrthancException(error); + } + return restart; }