Mercurial > hg > orthanc
changeset 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 | 97c8a7f93805 |
children | 0ae2ca210077 |
files | NEWS OrthancServer/Sources/OrthancConfiguration.cpp |
diffstat | 2 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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(); + } }