gui: improved error message when project import fails

This commit is contained in:
Daniel Marjamäki 2023-04-06 21:38:12 +02:00
parent aa73427699
commit 0d6575da15
1 changed files with 32 additions and 1 deletions

View File

@ -1687,7 +1687,38 @@ void MainWindow::analyzeProject(const ProjectFile *projectFile, const bool check
prjfile = inf.canonicalPath() + '/' + projectFile->getImportProject();
}
try {
p.import(prjfile.toStdString());
const ImportProject::Type result = p.import(prjfile.toStdString());
QString errorMessage;
switch (result) {
case ImportProject::Type::COMPILE_DB:
case ImportProject::Type::VS_SLN:
case ImportProject::Type::VS_VCXPROJ:
case ImportProject::Type::BORLAND:
case ImportProject::Type::CPPCHECK_GUI:
// Loading was successful
break;
case ImportProject::Type::MISSING:
errorMessage = tr("Failed to open file");
break;
case ImportProject::Type::UNKNOWN:
errorMessage = tr("Unknown project file format");
break;
case ImportProject::Type::FAILURE:
errorMessage = tr("Failed to import project file");
break;
}
if (!errorMessage.isEmpty()) {
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
tr("Failed to import '%1': %2\n\nAnalysis is stopped.").arg(prjfile).arg(errorMessage),
QMessageBox::Ok,
this);
msg.exec();
return;
}
} catch (InternalError &e) {
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),