From ebf9d9fd42d9654d6f8e4480fb47aa0a6f7d2865 Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Tue, 19 May 2026 23:15:44 +0800 Subject: [PATCH] feat: add UI feedback on http error and some logs (#13738) * feat: add UI feedback on http error and some logs * spelling fix * show error dialog only once per session * show errors with plater notification when on developer mode * remove return * remove irrelevant logs --- src/slic3r/GUI/GUI_App.cpp | 41 ++++++++++++++++++++++++++++++--- src/slic3r/GUI/GUI_App.hpp | 2 +- src/slic3r/GUI/ImGuiWrapper.hpp | 3 ++- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index b5204e1d49..9f2ce1c8f5 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -11,6 +11,7 @@ #include "Downloader.hpp" #include #include +#include #include // Localization headers: include libslic3r version first so everything in this file @@ -4844,12 +4845,12 @@ void GUI_App::on_http_error(wxCommandEvent &evt) BOOST_LOG_TRIVIAL(warning) << "logout: http error 401."; this->request_user_logout(provider); - if (!m_show_http_errpr_msgdlg) { + if (!m_show_http_error_msgdlg) { MessageDialog msg_dlg(nullptr, _L("Login information expired. Please login again."), "", wxAPPLY | wxOK); - m_show_http_errpr_msgdlg = true; + m_show_http_error_msgdlg = true; auto modal_result = msg_dlg.ShowModal(); if (modal_result == wxOK || modal_result == wxCLOSE) { - m_show_http_errpr_msgdlg = false; + m_show_http_error_msgdlg = false; return; } } @@ -4857,6 +4858,40 @@ void GUI_App::on_http_error(wxCommandEvent &evt) } return; } + + // No need to show dialog for 410: 410 means resource has been deleted from the server. + if (status == 410) { + BOOST_LOG_TRIVIAL(info) << "Http error 410."; + return; + } + + static bool m_is_error_shown = false; + // Show general error notification for Orca Cloud API failures (not Bambu) + if (provider == ORCA_CLOUD_PROVIDER && status >= 400 && code != HttpErrorVersionLimited) { + wxString msg; + if (!error.empty()) { + msg = wxString::Format(_L("API error (HTTP %u): %s"), status, wxString::FromUTF8(error)); + } else { + msg = wxString::Format(_L("API error (HTTP %u)"), status); + } + + if (app_config->get_bool("developer_mode")) { + // Use notification manager if ImGui is ready; fall back to wxMessageBox on Linux + // where ImGui may not be initialized until the user switches to the Prepare tab. + if (wxGetApp().plater() != nullptr && wxGetApp().imgui()->display_initialized()) { + wxGetApp() + .plater() + ->get_notification_manager() + ->push_notification(NotificationType::PlaterError, NotificationManager::NotificationLevel::WarningNotificationLevel, + msg.ToUTF8().data()); + } + } + + if (!m_is_error_shown) { + m_is_error_shown = true; + wxMessageBox(msg, _L("Orca Cloud API Error"), wxOK | wxICON_ERROR, wxGetApp().mainframe); + } + } } void GUI_App::enable_user_preset_folder(bool enable) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index fac853e65c..3212c719f5 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -324,7 +324,7 @@ private: bool m_is_dark_mode{ false }; bool m_adding_script_handler { false }; bool m_side_popup_status{false}; - bool m_show_http_errpr_msgdlg{false}; + bool m_show_http_error_msgdlg{false}; bool m_show_error_msgdlg{false}; wxString m_info_dialog_content; HttpServer m_http_server; diff --git a/src/slic3r/GUI/ImGuiWrapper.hpp b/src/slic3r/GUI/ImGuiWrapper.hpp index 8855a38405..af92140379 100644 --- a/src/slic3r/GUI/ImGuiWrapper.hpp +++ b/src/slic3r/GUI/ImGuiWrapper.hpp @@ -373,12 +373,13 @@ public: //BBS static int TOOLBAR_WINDOW_FLAGS; + bool display_initialized() const; + private: void init_font(bool compress); void init_input(); void init_style(); void render_draw_data(ImDrawData *draw_data); - bool display_initialized() const; void destroy_font(); std::vector load_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height, unsigned *outwidth, unsigned *outheight);