# HG changeset patch # User Sebastien Jodogne # Date 1604230998 -3600 # Node ID a20928107a90fb2bcfde199d04f1e8b70ab9296c # Parent 97c8a7f9380528f9f2f8b2ab3738b505714112f9 REST API returns 404 error if deleting an inexistent peer or modality diff -r 97c8a7f93805 -r a20928107a90 NEWS --- a/NEWS Fri Oct 30 12:00:16 2020 +0100 +++ b/NEWS Sun Nov 01 12:43:18 2020 +0100 @@ -3,6 +3,7 @@ * C-GET SCP: Fix responses and handling of cancel * Fix decoding sequence if "BuiltinDecoderTranscoderOrder" is "Before" +* REST API returns 404 error if deleting an inexistent peer or modality * Upgraded dependencies for static builds (notably on Windows and LSB): - civetweb 1.13 diff -r 97c8a7f93805 -r a20928107a90 OrthancServer/Sources/OrthancConfiguration.cpp --- a/OrthancServer/Sources/OrthancConfiguration.cpp Fri Oct 30 12:00:16 2020 +0100 +++ b/OrthancServer/Sources/OrthancConfiguration.cpp Sun Nov 01 12:43:18 2020 +0100 @@ -830,8 +830,16 @@ void OrthancConfiguration::RemoveModality(const std::string& symbolicName) { - modalities_.erase(symbolicName); - SaveModalities(); + if (modalities_.find(symbolicName) == modalities_.end()) + { + throw OrthancException(ErrorCode_InexistentItem, + "Unknown DICOM modality with symbolic name: " + symbolicName); + } + else + { + modalities_.erase(symbolicName); + SaveModalities(); + } } @@ -849,8 +857,16 @@ void OrthancConfiguration::RemovePeer(const std::string& symbolicName) { - peers_.erase(symbolicName); - SavePeers(); + if (peers_.find(symbolicName) == peers_.end()) + { + throw OrthancException(ErrorCode_InexistentItem, + "Unknown Orthanc peer: " + symbolicName); + } + else + { + peers_.erase(symbolicName); + SavePeers(); + } }