Pārlūkot izejas kodu

Handle retrieve failures in the Query/Retrieve widget

Throw exceptions from ctkDICOMRetrieve based on the error state.
TODO: should give better feedback to the user in the dialog, but
for now the error log includes the messages.
Steve Pieper 14 gadi atpakaļ
vecāks
revīzija
9e419460e3

+ 6 - 2
Libs/DICOM/Core/ctkDICOMRetrieve.cpp

@@ -18,6 +18,8 @@
 
 
 =========================================================================*/
 =========================================================================*/
 
 
+#include <stdexcept>
+
 // Qt includes
 // Qt includes
 #include <QSqlQuery>
 #include <QSqlQuery>
 #include <QSqlRecord>
 #include <QSqlRecord>
@@ -142,13 +144,13 @@ void ctkDICOMRetrievePrivate::retrieve ( QString UID, RetrieveType retriveType )
   if ( !scu.initNetwork().good() ) 
   if ( !scu.initNetwork().good() ) 
     {
     {
     logger.error ( "Error initializing the network" );
     logger.error ( "Error initializing the network" );
-    return;
+    throw std::runtime_error( std::string("Error initializing the network") );
     }
     }
   logger.debug ( "Negotiating Association" );
   logger.debug ( "Negotiating Association" );
   if ( !scu.negotiateAssociation().good() )
   if ( !scu.negotiateAssociation().good() )
     {
     {
     logger.error ( "Error negotiating association" );
     logger.error ( "Error negotiating association" );
-    return;
+    throw std::runtime_error( std::string("Error negotiating association") );
     }
     }
 
 
   logger.debug ( "Setting Parameters" );
   logger.debug ( "Setting Parameters" );
@@ -183,6 +185,7 @@ void ctkDICOMRetrievePrivate::retrieve ( QString UID, RetrieveType retriveType )
     if ( responses->begin() == responses->end() )
     if ( responses->begin() == responses->end() )
       {
       {
       logger.error ( "No responses!" );
       logger.error ( "No responses!" );
+      throw std::runtime_error( std::string("No responses!") );
       }
       }
 
 
     // Write the responses out to disk
     // Write the responses out to disk
@@ -229,6 +232,7 @@ void ctkDICOMRetrievePrivate::retrieve ( QString UID, RetrieveType retriveType )
   else
   else
     {
     {
     logger.error ( "MOVE Request failed: " + QString ( status.text() ) );
     logger.error ( "MOVE Request failed: " + QString ( status.text() ) );
+    throw std::runtime_error( std::string("Move Request Failed") );
     }
     }
   delete responses;
   delete responses;
 }
 }

+ 4 - 0
Libs/DICOM/Widgets/ctkDICOMQueryRetrieveWidget.cpp

@@ -25,6 +25,7 @@
 #include <QSettings>
 #include <QSettings>
 #include <QTreeView>
 #include <QTreeView>
 #include <QTabBar>
 #include <QTabBar>
+#include <QMessageBox>
 
 
 /// CTK includes
 /// CTK includes
 #include <ctkCheckableHeaderView.h>
 #include <ctkCheckableHeaderView.h>
@@ -221,10 +222,13 @@ void ctkDICOMQueryRetrieveWidget::processRetrieve()
     catch (std::exception e)
     catch (std::exception e)
       {
       {
       logger.error ( "Retrieve failed" );
       logger.error ( "Retrieve failed" );
+      QMessageBox::information ( this, tr("Query Retrieve"), tr("Retrieve failed.") );
       return;
       return;
       }
       }
     logger.info ( "Retrieve success" );
     logger.info ( "Retrieve success" );
   }
   }
+  QMessageBox::information ( this, tr("Query Retrieve"), tr("Selected studies have been downloaded.") );
+  this->hide();
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------