mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 00:01:09 -06:00
ENH:Show ErrorCode to the Device screen
Change-Id: I481b08a439d07a99f6c06c558e0a7fb3467a7d51
This commit is contained in:
parent
6eb4d671b5
commit
7a041ac2a0
11 changed files with 322 additions and 16 deletions
60
src/slic3r/GUI/UpdateErrorMessage.cpp
Normal file
60
src/slic3r/GUI/UpdateErrorMessage.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
#include "UpdateErrorMessage.hpp"
|
||||
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_UPDATE_ERROR_MESSAGE, wxCommandEvent);
|
||||
|
||||
std::string show_error_message(int error_code)
|
||||
{
|
||||
char buf[64];
|
||||
std::string result_str = "";
|
||||
std::sprintf(buf,"%08X",error_code);
|
||||
std::string hms_host = wxGetApp().app_config->get_hms_host();
|
||||
std::string get_lang = wxGetApp().app_config->get_langauge_code();
|
||||
|
||||
std::string url = (boost::format("https://%1%/query.php?lang=%2%&e=%3%")
|
||||
%hms_host
|
||||
%get_lang
|
||||
%buf).str();
|
||||
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
http.header("accept", "application/json")
|
||||
.timeout_max(10)
|
||||
.on_complete([get_lang, &result_str](std::string body, unsigned status) {
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("result")) {
|
||||
if (j["result"].get<int>() == 0) {
|
||||
if (j.contains("data")) {
|
||||
json jj = j["data"];
|
||||
if (jj.contains("device_error")) {
|
||||
if (jj["device_error"].contains(get_lang)) {
|
||||
if (jj["device_error"][get_lang].size() > 0) {
|
||||
if (!jj["device_error"][get_lang][0]["intro"].empty() || !jj["device_error"][get_lang][0]["ecode"].empty()) {
|
||||
std::string error_info = jj["device_error"][get_lang][0]["intro"].get<std::string>();
|
||||
std::string error_code = jj["device_error"][get_lang][0]["ecode"].get<std::string>();
|
||||
error_code.insert(4, " ");
|
||||
result_str = from_u8(error_info).ToStdString() + "[" + error_code + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_error([](std::string body, std::string error, unsigned status) {
|
||||
BOOST_LOG_TRIVIAL(trace) << boost::format("[BBL ErrorMessage]: status=%1%, error=%2%, body=%3%") % status % error % body;
|
||||
}).perform_sync();
|
||||
|
||||
return result_str;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue