mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-27 00:24:00 -06:00
NEW:optimizing error info for network requests
Change-Id: I8656c2f899b086b5ab52d94b7186e64df1625e3e
This commit is contained in:
parent
7b12dcb6ea
commit
8b490adc51
27 changed files with 1133 additions and 637 deletions
|
@ -16,22 +16,6 @@ static wxString waiting_auth_str = _L("Logging in");
|
|||
static wxString login_failed_str = _L("Login failed");
|
||||
|
||||
|
||||
wxString get_login_fail_reason(std::string fail_reason)
|
||||
{
|
||||
if (fail_reason == "NO Regions")
|
||||
return _L("The region parameter is incorrrect");
|
||||
else if (fail_reason == "Cloud Timeout")
|
||||
return _L("Failure of printer login");
|
||||
else if (fail_reason == "Ticket Failed")
|
||||
return _L("Failed to get ticket");
|
||||
else if (fail_reason == "Wait Auth Timeout")
|
||||
return _L("User authorization timeout");
|
||||
else if (fail_reason == "Bind Failure")
|
||||
return _L("Failure of bind");
|
||||
else
|
||||
return _L("Unknown Failure");
|
||||
}
|
||||
|
||||
BindJob::BindJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater, std::string dev_id, std::string dev_ip, std::string sec_link)
|
||||
: PlaterJob{std::move(pri), plater},
|
||||
m_dev_id(dev_id),
|
||||
|
@ -59,7 +43,6 @@ void BindJob::on_success(std::function<void()> success)
|
|||
void BindJob::update_status(int st, const wxString &msg)
|
||||
{
|
||||
GUI::Job::update_status(st, msg);
|
||||
//post_event(wxCommandEvent(EVT_BIND_UPDATE_MESSAGE), msg);
|
||||
wxCommandEvent event(EVT_BIND_UPDATE_MESSAGE);
|
||||
event.SetString(msg);
|
||||
event.SetEventObject(m_event_handle);
|
||||
|
@ -68,6 +51,9 @@ void BindJob::update_status(int st, const wxString &msg)
|
|||
|
||||
void BindJob::process()
|
||||
{
|
||||
int result_code = 0;
|
||||
std::string result_info;
|
||||
|
||||
/* display info */
|
||||
wxString msg = waiting_auth_str;
|
||||
int curr_percent = 0;
|
||||
|
@ -81,7 +67,11 @@ void BindJob::process()
|
|||
std::string timezone = get_timezone_utc_hm(offset);
|
||||
|
||||
int result = m_agent->bind(m_dev_ip, m_dev_id, m_sec_link, timezone,
|
||||
[this, &curr_percent, &msg](int stage, int code, std::string info) {
|
||||
[this, &curr_percent, &msg, &result_code, &result_info](int stage, int code, std::string info) {
|
||||
|
||||
result_code = code;
|
||||
result_info = info;
|
||||
|
||||
if (stage == BBL::BindJobStage::LoginStageConnect) {
|
||||
curr_percent = 15;
|
||||
msg = _L("Logging in");
|
||||
|
@ -103,8 +93,9 @@ void BindJob::process()
|
|||
} else {
|
||||
msg = _L("Logging in");
|
||||
}
|
||||
|
||||
if (code != 0) {
|
||||
msg = _L("Login failed") + wxString::Format("(code=%d,info=%s). ", code, info);
|
||||
msg = _L("Login failed");
|
||||
if (code == BAMBU_NETWORK_ERR_TIMEOUT) {
|
||||
msg += _L("Please check the printer network connection.");
|
||||
}
|
||||
|
@ -115,14 +106,14 @@ void BindJob::process()
|
|||
|
||||
if (result < 0) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "login: result = " << result;
|
||||
post_fail_event();
|
||||
post_fail_event(result_code, result_info);
|
||||
return;
|
||||
}
|
||||
|
||||
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "login: dev is null";
|
||||
post_fail_event();
|
||||
post_fail_event(result_code, result_info);
|
||||
return;
|
||||
}
|
||||
dev->update_user_machine_list_info();
|
||||
|
@ -145,9 +136,11 @@ void BindJob::set_event_handle(wxWindow *hanle)
|
|||
m_event_handle = hanle;
|
||||
}
|
||||
|
||||
void BindJob::post_fail_event()
|
||||
void BindJob::post_fail_event(int code, std::string info)
|
||||
{
|
||||
wxCommandEvent event(EVT_BIND_MACHINE_FAIL);
|
||||
event.SetInt(code);
|
||||
event.SetString(info);
|
||||
event.SetEventObject(m_event_handle);
|
||||
wxPostEvent(m_event_handle, event);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue