Improve formatting of error messages

This commit is contained in:
Aurélien Gâteau 2014-08-01 09:56:40 +02:00
parent b111027d57
commit 90670f8b46
3 changed files with 18 additions and 21 deletions

View File

@ -270,9 +270,14 @@ Helper::handleLastError()
msgList.append( valMsg ); msgList.append( valMsg );
if ( !tbMsg.isEmpty() ) if ( !tbMsg.isEmpty() )
msgList.append( QString( "</code>Traceback:<code><br/>%1" ).arg( tbMsg ) ); {
msgList.append( "Traceback:" );
msgList.append( QString( "<pre>%1</pre>" ).arg( tbMsg ) );
cDebug() << "tbMsg" << tbMsg;
}
return QString( "<code>%1</code>" ).arg( msgList.join( "<br/>" ) ); // Return a string made of the msgList items, wrapped in <div> tags
return QString( "<div>%1</div>" ).arg( msgList.join( "</div><div>" ) );
} }

View File

@ -195,11 +195,7 @@ PythonJob::exec()
bp::tuple resultTuple = bp::extract< bp::tuple >( runResult ); bp::tuple resultTuple = bp::extract< bp::tuple >( runResult );
QString message = QString::fromStdString( bp::extract< std::string >( resultTuple[ 0 ] ) ); QString message = QString::fromStdString( bp::extract< std::string >( resultTuple[ 0 ] ) );
QString description = QString::fromStdString( bp::extract< std::string >( resultTuple[ 1 ] ) ); QString description = QString::fromStdString( bp::extract< std::string >( resultTuple[ 1 ] ) );
return JobResult::error( tr( "Job \"%1\" finished with error" ) return JobResult::error( message, description );
.arg( prettyName() ),
QString( "<strong>%1</strong><br/>%2" )
.arg( message )
.arg( description ) );
} }
} }
catch ( bp::error_already_set ) catch ( bp::error_already_set )
@ -211,7 +207,7 @@ PythonJob::exec()
} }
bp::handle_exception(); bp::handle_exception();
PyErr_Clear(); PyErr_Clear();
return JobResult::error( tr( "Boost.Python error in job \"%1\"" ).arg( prettyName() ), return JobResult::error( tr( "Boost.Python error in job \"%1\"." ).arg( prettyName() ),
msg ); msg );
} }

View File

@ -116,24 +116,20 @@ ViewManager::insertViewStep( int before, ViewStep* step)
void void
ViewManager::onInstallationFailed( const QString& message, const QString& details ) ViewManager::onInstallationFailed( const QString& message, const QString& details )
{ {
QString text = tr( QMessageBox msgBox;
"<p><b>Installation Failed</b></p>" msgBox.setIcon( QMessageBox::Critical );
"<p>%1</p>" msgBox.setWindowTitle( tr("Error") );
).arg( message ); msgBox.setText( "<strong>" + tr( "Installation Failed" ) + "</strong>" );
msgBox.setStandardButtons( QMessageBox::Close );
QString text = "<p>" + message + "</p>";
if ( !details.isEmpty() ) if ( !details.isEmpty() )
{ {
text += tr( text += "<p>" + details + "</p>";
"<p>%1</p>"
).arg( details );
} }
msgBox.setInformativeText( text );
QMessageBox::critical( msgBox.exec();
QApplication::activeWindow(),
tr( "Error" ),
text,
QMessageBox::Close
);
QApplication::quit(); QApplication::quit();
} }