comparison OrthancServer/DicomProtocol/DicomUserConnection.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 7dae55228b16
comparison
equal deleted inserted replaced
1581:357c4bb15701 1582:bd1889029cbb
297 // Figure out which SOP class and SOP instance is encapsulated in the file 297 // Figure out which SOP class and SOP instance is encapsulated in the file
298 DIC_UI sopClass; 298 DIC_UI sopClass;
299 DIC_UI sopInstance; 299 DIC_UI sopInstance;
300 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance)) 300 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance))
301 { 301 {
302 throw OrthancException("DicomUserConnection: Unable to find the SOP class and instance"); 302 throw OrthancException(ErrorCode_NoSopClassOrInstance);
303 } 303 }
304 304
305 // Figure out which of the accepted presentation contexts should be used 305 // Figure out which of the accepted presentation contexts should be used
306 int presID = ASC_findAcceptedPresentationContextID(assoc_, sopClass); 306 int presID = ASC_findAcceptedPresentationContextID(assoc_, sopClass);
307 if (presID == 0) 307 if (presID == 0)
308 { 308 {
309 const char *modalityName = dcmSOPClassUIDToModality(sopClass); 309 const char *modalityName = dcmSOPClassUIDToModality(sopClass);
310 if (!modalityName) modalityName = dcmFindNameOfUID(sopClass); 310 if (!modalityName) modalityName = dcmFindNameOfUID(sopClass);
311 if (!modalityName) modalityName = "unknown SOP class"; 311 if (!modalityName) modalityName = "unknown SOP class";
312 throw OrthancException("DicomUserConnection: No presentation context for modality " + 312 throw OrthancException(ErrorCode_NoPresentationContext);
313 std::string(modalityName));
314 } 313 }
315 314
316 // Prepare the transmission of data 315 // Prepare the transmission of data
317 T_DIMSE_C_StoreRQ req; 316 T_DIMSE_C_StoreRQ req;
318 memset(&req, 0, sizeof(req)); 317 memset(&req, 0, sizeof(req));
550 549
551 // Figure out which of the accepted presentation contexts should be used 550 // Figure out which of the accepted presentation contexts should be used
552 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass); 551 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass);
553 if (presID == 0) 552 if (presID == 0)
554 { 553 {
555 throw OrthancException("DicomUserConnection: The C-FIND command is not supported by the remote AET"); 554 throw OrthancException(ErrorCode_DicomFindUnavailable);
556 } 555 }
557 556
558 T_DIMSE_C_FindRQ request; 557 T_DIMSE_C_FindRQ request;
559 memset(&request, 0, sizeof(request)); 558 memset(&request, 0, sizeof(request));
560 request.MessageID = pimpl_->assoc_->nextMsgID++; 559 request.MessageID = pimpl_->assoc_->nextMsgID++;
623 622
624 // Figure out which of the accepted presentation contexts should be used 623 // Figure out which of the accepted presentation contexts should be used
625 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass); 624 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass);
626 if (presID == 0) 625 if (presID == 0)
627 { 626 {
628 throw OrthancException("DicomUserConnection: The C-MOVE command is not supported by the remote AET"); 627 throw OrthancException(ErrorCode_DicomMoveUnavailable);
629 } 628 }
630 629
631 T_DIMSE_C_MoveRQ request; 630 T_DIMSE_C_MoveRQ request;
632 memset(&request, 0, sizeof(request)); 631 memset(&request, 0, sizeof(request));
633 request.MessageID = pimpl_->assoc_->nextMsgID++; 632 request.MessageID = pimpl_->assoc_->nextMsgID++;
774 { 773 {
775 if (remoteHost_ != host) 774 if (remoteHost_ != host)
776 { 775 {
777 if (host.size() > HOST_NAME_MAX - 10) 776 if (host.size() > HOST_NAME_MAX - 10)
778 { 777 {
779 throw OrthancException("Remote host name is too long"); 778 throw OrthancException(ErrorCode_ParameterOutOfRange);
780 } 779 }
781 780
782 Close(); 781 Close();
783 remoteHost_ = host; 782 remoteHost_ = host;
784 } 783 }
835 // Do the association 834 // Do the association
836 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_)); 835 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_));
837 836
838 if (ASC_countAcceptedPresentationContexts(pimpl_->params_) == 0) 837 if (ASC_countAcceptedPresentationContexts(pimpl_->params_) == 0)
839 { 838 {
840 throw OrthancException("DicomUserConnection: No Acceptable Presentation Contexts"); 839 throw OrthancException(ErrorCode_NoPresentationContext);
841 } 840 }
842 } 841 }
843 842
844 void DicomUserConnection::Close() 843 void DicomUserConnection::Close()
845 { 844 {