Mercurial > hg > orthanc
comparison OrthancServer/DicomProtocol/DicomServer.cpp @ 1582:bd1889029cbb
encoding of exceptions
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 Aug 2015 17:39:38 +0200 |
parents | f967bdf8534e |
children | d3ba98d6b6e9 |
comparison
equal
deleted
inserted
replaced
1581:357c4bb15701 | 1582:bd1889029cbb |
---|---|
160 OFCondition cond = ASC_initializeNetwork | 160 OFCondition cond = ASC_initializeNetwork |
161 (NET_ACCEPTOR, OFstatic_cast(int, server->port_), /*opt_acse_timeout*/ 30, &net); | 161 (NET_ACCEPTOR, OFstatic_cast(int, server->port_), /*opt_acse_timeout*/ 30, &net); |
162 if (cond.bad()) | 162 if (cond.bad()) |
163 { | 163 { |
164 LOG(ERROR) << "cannot create network: " << cond.text(); | 164 LOG(ERROR) << "cannot create network: " << cond.text(); |
165 throw OrthancException("Cannot create network"); | 165 throw OrthancException(ErrorCode_DicomPortInUse); |
166 } | 166 } |
167 | 167 |
168 LOG(INFO) << "DICOM server started"; | 168 LOG(INFO) << "DICOM server started"; |
169 | 169 |
170 server->started_ = true; | 170 server->started_ = true; |
277 | 277 |
278 void DicomServer::SetApplicationEntityTitle(const std::string& aet) | 278 void DicomServer::SetApplicationEntityTitle(const std::string& aet) |
279 { | 279 { |
280 if (aet.size() == 0) | 280 if (aet.size() == 0) |
281 { | 281 { |
282 throw OrthancException("Too short AET"); | 282 throw OrthancException(ErrorCode_BadApplicationEntityTitle); |
283 } | 283 } |
284 | 284 |
285 if (aet.size() > 16) | 285 if (aet.size() > 16) |
286 { | 286 { |
287 throw OrthancException("AET must be shorter than 16 characters"); | 287 throw OrthancException(ErrorCode_BadApplicationEntityTitle); |
288 } | 288 } |
289 | 289 |
290 for (size_t i = 0; i < aet.size(); i++) | 290 for (size_t i = 0; i < aet.size(); i++) |
291 { | 291 { |
292 if (!(aet[i] == '-' || | 292 if (!(aet[i] == '-' || |
325 { | 325 { |
326 return *findRequestHandlerFactory_; | 326 return *findRequestHandlerFactory_; |
327 } | 327 } |
328 else | 328 else |
329 { | 329 { |
330 throw OrthancException("No C-FIND request handler factory"); | 330 throw OrthancException(ErrorCode_NoCFindHandler); |
331 } | 331 } |
332 } | 332 } |
333 | 333 |
334 void DicomServer::SetMoveRequestHandlerFactory(IMoveRequestHandlerFactory& factory) | 334 void DicomServer::SetMoveRequestHandlerFactory(IMoveRequestHandlerFactory& factory) |
335 { | 335 { |
348 { | 348 { |
349 return *moveRequestHandlerFactory_; | 349 return *moveRequestHandlerFactory_; |
350 } | 350 } |
351 else | 351 else |
352 { | 352 { |
353 throw OrthancException("No C-MOVE request handler factory"); | 353 throw OrthancException(ErrorCode_NoCMoveHandler); |
354 } | 354 } |
355 } | 355 } |
356 | 356 |
357 void DicomServer::SetStoreRequestHandlerFactory(IStoreRequestHandlerFactory& factory) | 357 void DicomServer::SetStoreRequestHandlerFactory(IStoreRequestHandlerFactory& factory) |
358 { | 358 { |
371 { | 371 { |
372 return *storeRequestHandlerFactory_; | 372 return *storeRequestHandlerFactory_; |
373 } | 373 } |
374 else | 374 else |
375 { | 375 { |
376 throw OrthancException("No C-STORE request handler factory"); | 376 throw OrthancException(ErrorCode_NoCStoreHandler); |
377 } | 377 } |
378 } | 378 } |
379 | 379 |
380 void DicomServer::SetApplicationEntityFilter(IApplicationEntityFilter& factory) | 380 void DicomServer::SetApplicationEntityFilter(IApplicationEntityFilter& factory) |
381 { | 381 { |
394 { | 394 { |
395 return *applicationEntityFilter_; | 395 return *applicationEntityFilter_; |
396 } | 396 } |
397 else | 397 else |
398 { | 398 { |
399 throw OrthancException("No application entity filter"); | 399 throw OrthancException(ErrorCode_NoApplicationEntityFilter); |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 void DicomServer::Start() | 403 void DicomServer::Start() |
404 { | 404 { |