Skip to content
Snippets Groups Projects
Commit 15192b63 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: better handling of exceptions thrown during DoUpdateParameters()

parent 58429325
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ public:
public slots:
void CloseSlot();
void UnhandledException(QString message);
void OnExceptionRaised(QString message);
private slots:
void UpdateMessageAfterExecuteClicked();
......
......@@ -70,7 +70,42 @@ QtWidgetModel
::NotifyUpdate()
{
// Update the parameters
m_Application->UpdateParameters();
try
{
m_Application->UpdateParameters();
}
catch(otb::ApplicationException& err)
{
m_Application->GetLogger()->Debug("Caught otb::ApplicationException during application update:\n");
m_Application->GetLogger()->Debug(string(err.what()) + "\n");
emit ExceptionRaised( err.what() );
}
catch(otb::ImageFileReaderException& err)
{
m_Application->GetLogger()->Debug("Caught otb::ImageFileReaderException during application update:\n");
m_Application->GetLogger()->Debug(string(err.what()) + "\n");
string message( string("Cannot open image ") + err.m_Filename + string(". ") + err.GetDescription() );
m_Application->GetLogger()->Fatal( message + string("\n"));
emit ExceptionRaised( message.c_str() );
}
catch(itk::ExceptionObject& err)
{
m_Application->GetLogger()->Debug("Caught itk::ExceptionObject during application update:\n");
m_Application->GetLogger()->Debug(string(err.what()) + "\n");
m_Application->GetLogger()->Fatal(string(err.GetDescription()) + "\n");
emit ExceptionRaised( err.GetDescription() );
}
catch(std::exception& err)
{
m_Application->GetLogger()->Fatal(string("Caught std::exception during application update: ") + err.what() + "\n");
emit ExceptionRaised( err.what() );
}
catch(...)
{
m_Application->GetLogger()->Fatal("Caught unknown exception during application update.\n");
emit ExceptionRaised("Unknown exception");
}
emit UpdateGui();
// Notify all
......
......@@ -82,6 +82,8 @@ void QtWidgetView::CreateGui()
QVBoxLayout *finalLayout = new QVBoxLayout();
finalLayout->addWidget(mainGroup);
connect( m_Model, SIGNAL(ExceptionRaised(QString)), this, SLOT(OnExceptionRaised(QString)) );
// Make the final layout to the widget
this->setLayout(finalLayout);
}
......@@ -188,9 +190,14 @@ void QtWidgetView::CloseSlot()
void QtWidgetView::UnhandledException(QString message)
{
m_TabWidget->setCurrentIndex(1);
this->OnExceptionRaised(message);
m_LogText->append(message);
}
void QtWidgetView::OnExceptionRaised(QString message)
{
m_TabWidget->setCurrentIndex(1);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment