Searcher: catch exception when loading node

This commit is contained in:
Le Tan 2021-08-12 21:49:06 +08:00
parent 0cf0da06f8
commit a0594dcc2b
2 changed files with 11 additions and 2 deletions

View File

@ -5,6 +5,7 @@
#include <buffer/buffer.h> #include <buffer/buffer.h>
#include <core/file.h> #include <core/file.h>
#include <core/exception.h>
#include <notebook/node.h> #include <notebook/node.h>
#include <notebook/notebook.h> #include <notebook/notebook.h>
@ -348,7 +349,15 @@ bool Searcher::firstPhaseSearchFolder(Node *p_node, QVector<SearchSecondPhaseIte
Q_ASSERT(p_node->isContainer()); Q_ASSERT(p_node->isContainer());
Q_ASSERT(testTarget(SearchTarget::SearchFile) || testTarget(SearchTarget::SearchFolder)); Q_ASSERT(testTarget(SearchTarget::SearchFile) || testTarget(SearchTarget::SearchFolder));
try {
p_node->load(); p_node->load();
} catch (Exception &p_e) {
QString msg = tr("Failed to load node to search (%1) (%2).")
.arg(p_node->getName(), p_e.what());
qCritical() << msg;
emit logRequested(msg);
return false;
}
if (testTarget(SearchTarget::SearchFolder)) { if (testTarget(SearchTarget::SearchFolder)) {
const auto name = p_node->getName(); const auto name = p_node->getName();

View File

@ -10,7 +10,7 @@
#include <notebook/notebook.h> #include <notebook/notebook.h>
#include <notebook/node.h> #include <notebook/node.h>
#include <notebook/externalnode.h> #include <notebook/externalnode.h>
#include "exception.h" #include <core/exception.h>
#include "messageboxhelper.h" #include "messageboxhelper.h"
#include "vnotex.h" #include "vnotex.h"
#include "mainwindow.h" #include "mainwindow.h"