Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
1674:4fc502d469f4 | 1675:131136aeeaa7 |
---|---|
570 dicomServer.SetApplicationEntityFilter(dicomFilter); | 570 dicomServer.SetApplicationEntityFilter(dicomFilter); |
571 | 571 |
572 dicomServer.Start(); | 572 dicomServer.Start(); |
573 LOG(WARNING) << "DICOM server listening on port: " << dicomServer.GetPortNumber(); | 573 LOG(WARNING) << "DICOM server listening on port: " << dicomServer.GetPortNumber(); |
574 | 574 |
575 bool restart = StartHttpServer(context, restApi, plugins); | 575 bool restart; |
576 ErrorCode error = ErrorCode_Success; | |
577 | |
578 try | |
579 { | |
580 restart = StartHttpServer(context, restApi, plugins); | |
581 } | |
582 catch (OrthancException& e) | |
583 { | |
584 error = e.GetErrorCode(); | |
585 } | |
576 | 586 |
577 dicomServer.Stop(); | 587 dicomServer.Stop(); |
578 LOG(WARNING) << " DICOM server has stopped"; | 588 LOG(WARNING) << " DICOM server has stopped"; |
579 | 589 |
580 serverFactory.Done(); | 590 serverFactory.Done(); |
591 | |
592 if (error != ErrorCode_Success) | |
593 { | |
594 throw OrthancException(error); | |
595 } | |
581 | 596 |
582 return restart; | 597 return restart; |
583 } | 598 } |
584 | 599 |
585 | 600 |
692 plugins->SetServerContext(context); | 707 plugins->SetServerContext(context); |
693 context.SetPlugins(*plugins); | 708 context.SetPlugins(*plugins); |
694 } | 709 } |
695 #endif | 710 #endif |
696 | 711 |
697 bool restart = ConfigureHttpHandler(context, plugins); | 712 bool restart; |
713 ErrorCode error = ErrorCode_Success; | |
714 | |
715 try | |
716 { | |
717 restart = ConfigureHttpHandler(context, plugins); | |
718 } | |
719 catch (OrthancException& e) | |
720 { | |
721 error = e.GetErrorCode(); | |
722 } | |
723 | |
698 context.Stop(); | 724 context.Stop(); |
699 | 725 |
700 #if ORTHANC_PLUGINS_ENABLED == 1 | 726 #if ORTHANC_PLUGINS_ENABLED == 1 |
701 if (plugins) | 727 if (plugins) |
702 { | 728 { |
703 context.ResetPlugins(); | 729 context.ResetPlugins(); |
704 } | 730 } |
705 #endif | 731 #endif |
732 | |
733 if (error != ErrorCode_Success) | |
734 { | |
735 throw OrthancException(error); | |
736 } | |
706 | 737 |
707 return restart; | 738 return restart; |
708 } | 739 } |
709 | 740 |
710 | 741 |