From 632c484dd5e1f18a6c63b7505bd773d448b86661 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 4 Jul 2024 06:27:54 +0800 Subject: [PATCH] replay: handle route not found error with user warning message (#32895) handle 404 --- tools/cabana/streams/replaystream.cc | 3 +++ tools/replay/route.cc | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/tools/cabana/streams/replaystream.cc b/tools/cabana/streams/replaystream.cc index bdb9ebb014..302a25696e 100644 --- a/tools/cabana/streams/replaystream.cc +++ b/tools/cabana/streams/replaystream.cc @@ -73,6 +73,9 @@ bool ReplayStream::loadRoute(const QString &route, const QString &data_dir, uint } else if (replay->lastRouteError() == RouteLoadError::NetworkError) { QMessageBox::warning(nullptr, tr("Network Error"), tr("Unable to load the route:\n\n %1.\n\nPlease check your network connection and try again.").arg(route)); + } else if (replay->lastRouteError() == RouteLoadError::FileNotFound) { + QMessageBox::warning(nullptr, tr("Route Not Found"), + tr("The specified route could not be found:\n\n %1.\n\nPlease check the route name and try again.").arg(route)); } else { QMessageBox::warning(nullptr, tr("Route Load Failed"), tr("Failed to load route: '%1'").arg(route)); } diff --git a/tools/replay/route.cc b/tools/replay/route.cc index 18c962abd5..716b02961e 100644 --- a/tools/replay/route.cc +++ b/tools/replay/route.cc @@ -39,6 +39,7 @@ RouteIdentifier Route::parseRoute(const QString &str) { } bool Route::load() { + err_ = RouteLoadError::None; if (route_.str.isEmpty() || (data_dir_.isEmpty() && route_.dongle_id.isEmpty())) { rInfo("invalid route format"); return false; @@ -76,6 +77,10 @@ bool Route::loadFromServer(int retries) { rWarning(">> Unauthorized. Authenticate with tools/lib/auth.py <<"); err_ = RouteLoadError::AccessDenied; return false; + } else if (err == QNetworkReply::ContentNotFoundError) { + rWarning("The specified route could not be found on the server."); + err_ = RouteLoadError::FileNotFound; + return false; } else { err_ = RouteLoadError::NetworkError; }