Mercurial > hg > orthanc-transfers
comparison Framework/DownloadArea.cpp @ 40:1256194e1c08
sync orthanc + sdk 1.5.0 + added more info in error logs
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 12 Jul 2022 12:43:43 +0200 |
parents | 44a0430d7899 |
children | 1e396fb509ca |
comparison
equal
deleted
inserted
replaced
39:f627882388dc | 40:1256194e1c08 |
---|---|
53 stream_.open(f.GetPath(), std::ofstream::in | std::ofstream::out | std::ofstream::binary); | 53 stream_.open(f.GetPath(), std::ofstream::in | std::ofstream::out | std::ofstream::binary); |
54 } | 54 } |
55 | 55 |
56 if (!stream_.good()) | 56 if (!stream_.good()) |
57 { | 57 { |
58 throw Orthanc::OrthancException(Orthanc::ErrorCode_CannotWriteFile); | 58 throw Orthanc::OrthancException(Orthanc::ErrorCode_CannotWriteFile, std::string("Unable to write to ") + f.GetPath()); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 void Write(size_t offset, | 62 void Write(size_t offset, |
63 const void* data, | 63 const void* data, |
86 const void* data, | 86 const void* data, |
87 size_t size) | 87 size_t size) |
88 { | 88 { |
89 if (offset + size > info_.GetSize()) | 89 if (offset + size > info_.GetSize()) |
90 { | 90 { |
91 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 91 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, "WriteChunk out of bounds"); |
92 } | 92 } |
93 else if (size > 0) | 93 else if (size > 0) |
94 { | 94 { |
95 Writer writer(file_, false); | 95 Writer writer(file_, false); |
96 writer.Write(offset, data, size); | 96 writer.Write(offset, data, size); |
149 { | 149 { |
150 Instances::iterator it = instances_.find(id); | 150 Instances::iterator it = instances_.find(id); |
151 | 151 |
152 if (it == instances_.end()) | 152 if (it == instances_.end()) |
153 { | 153 { |
154 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | 154 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource, "Unknown instance"); |
155 } | 155 } |
156 else if (it->first != id || | 156 else if (it->first != id || |
157 it->second == NULL) | 157 it->second == NULL) |
158 { | 158 { |
159 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | 159 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
169 const void* data, | 169 const void* data, |
170 size_t size) | 170 size_t size) |
171 { | 171 { |
172 if (size != bucket.GetTotalSize()) | 172 if (size != bucket.GetTotalSize()) |
173 { | 173 { |
174 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); | 174 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol, |
175 "WriteUncompressedBucket: " + boost::lexical_cast<std::string>(size) + " != " + boost::lexical_cast<std::string>(bucket.GetTotalSize())); | |
175 } | 176 } |
176 | 177 |
177 if (size == 0) | 178 if (size == 0) |
178 { | 179 { |
179 return; | 180 return; |