comparison OrthancServer/Sources/OrthancConfiguration.cpp @ 4267:a20928107a90

REST API returns 404 error if deleting an inexistent peer or modality
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 01 Nov 2020 12:43:18 +0100
parents 318c16cfccab
children 3af1d763763a
comparison
equal deleted inserted replaced
4266:97c8a7f93805 4267:a20928107a90
828 } 828 }
829 829
830 830
831 void OrthancConfiguration::RemoveModality(const std::string& symbolicName) 831 void OrthancConfiguration::RemoveModality(const std::string& symbolicName)
832 { 832 {
833 modalities_.erase(symbolicName); 833 if (modalities_.find(symbolicName) == modalities_.end())
834 SaveModalities(); 834 {
835 throw OrthancException(ErrorCode_InexistentItem,
836 "Unknown DICOM modality with symbolic name: " + symbolicName);
837 }
838 else
839 {
840 modalities_.erase(symbolicName);
841 SaveModalities();
842 }
835 } 843 }
836 844
837 845
838 void OrthancConfiguration::UpdatePeer(const std::string& symbolicName, 846 void OrthancConfiguration::UpdatePeer(const std::string& symbolicName,
839 const WebServiceParameters& peer) 847 const WebServiceParameters& peer)
847 } 855 }
848 856
849 857
850 void OrthancConfiguration::RemovePeer(const std::string& symbolicName) 858 void OrthancConfiguration::RemovePeer(const std::string& symbolicName)
851 { 859 {
852 peers_.erase(symbolicName); 860 if (peers_.find(symbolicName) == peers_.end())
853 SavePeers(); 861 {
862 throw OrthancException(ErrorCode_InexistentItem,
863 "Unknown Orthanc peer: " + symbolicName);
864 }
865 else
866 {
867 peers_.erase(symbolicName);
868 SavePeers();
869 }
854 } 870 }
855 871
856 872
857 void OrthancConfiguration::Format(std::string& result) const 873 void OrthancConfiguration::Format(std::string& result) const
858 { 874 {