Use network_error_code from callbacks

Signed-off-by: 0x189D7997 <199489335+0x189D7997@users.noreply.github.com>
(cherry picked from commit 364968a6b4)
This commit is contained in:
0x189D7997 2026-04-07 12:57:09 +00:00 committed by github-actions[bot]
parent c06cc8f9ae
commit 6b60a243bc
2 changed files with 10 additions and 11 deletions

View file

@ -141,14 +141,14 @@ void ModpackListModel::performPaginatedSearch()
if (!projectId.isEmpty()) {
ResourceAPI::Callback<ModPlatform::IndexedPack::Ptr> callbacks;
callbacks.on_fail = [this](QString reason, int) {
callbacks.on_fail = [this](QString reason, int network_error_code) {
m_searchState = ResetRequested;
searchRequestFailed(reason);
searchRequestFailed(reason, network_error_code);
};
callbacks.on_succeed = [this](auto& pack) { searchRequestForOneSucceeded(pack); };
callbacks.on_abort = [this] {
qCritical() << "Search task aborted by an unknown reason!";
searchRequestFailed("Aborted");
searchRequestFailed("Aborted", 0);
};
auto project = std::make_shared<ModPlatform::IndexedPack>();
project->addonId = projectId;
@ -165,10 +165,10 @@ void ModpackListModel::performPaginatedSearch()
ResourceAPI::Callback<QList<ModPlatform::IndexedPack::Ptr>> callbacks{};
callbacks.on_succeed = [this](auto& doc) { searchRequestFinished(doc); };
callbacks.on_fail = [this](QString reason, int) { searchRequestFailed(reason); };
callbacks.on_fail = [this](QString reason, int network_error_code) { searchRequestFailed(reason, network_error_code); };
callbacks.on_abort = [this] {
qCritical() << "Search task aborted by an unknown reason!";
searchRequestFailed("Aborted");
searchRequestFailed("Aborted", 0);
};
auto netJob = api.searchProjects({ ModPlatform::ResourceType::Modpack, m_nextSearchOffset, m_currentSearchTerm, sort, m_filter->loaders,
@ -320,13 +320,12 @@ void ModpackListModel::searchRequestForOneSucceeded(ModPlatform::IndexedPack::Pt
endInsertRows();
}
void ModpackListModel::searchRequestFailed(QString)
void ModpackListModel::searchRequestFailed(QString reason, int network_error_code)
{
auto failed_action = dynamic_cast<NetJob*>(m_jobPtr.get())->getFailedActions().at(0);
if (failed_action->replyStatusCode() == -1) {
// Network error
if (network_error_code == -1) {
// Unknown error in network stack
QMessageBox::critical(nullptr, tr("Error"), tr("A network error occurred. Could not load modpacks."));
} else if (failed_action->replyStatusCode() == 409) {
} else if (network_error_code == 409) {
// 409 Gone, notify user to update
QMessageBox::critical(nullptr, tr("Error"),
//: %1 refers to the launcher itself

View file

@ -85,7 +85,7 @@ class ModpackListModel : public QAbstractListModel {
public slots:
void searchRequestFinished(QList<ModPlatform::IndexedPack::Ptr>& doc_all);
void searchRequestFailed(QString reason);
void searchRequestFailed(QString reason, int network_error_code);
void searchRequestForOneSucceeded(ModPlatform::IndexedPack::Ptr);
protected slots: