mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -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
|
@ -2,27 +2,31 @@
|
|||
#include "libslic3r/MTUtils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "bambu_networking.hpp"
|
||||
#include "slic3r/GUI/Plater.hpp"
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "bambu_networking.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
static wxString check_gcode_failed_str = _L("Abnormal print file data. Please slice again");
|
||||
static wxString printjob_cancel_str = _L("Task canceled");
|
||||
static wxString timeout_to_upload_str = _L("Upload task timed out. Please check the network problem and try again");
|
||||
static wxString check_gcode_failed_str = _L("Abnormal print file data. Please slice again.");
|
||||
static wxString printjob_cancel_str = _L("Task canceled.");
|
||||
static wxString timeout_to_upload_str = _L("Upload task timed out. Please check the network status and try again.");
|
||||
static wxString failed_in_cloud_service_str = _L("Cloud service connection failed. Please try again.");
|
||||
static wxString file_is_not_exists_str = _L("Print file not found, please slice again");
|
||||
static wxString file_over_size_str = _L("The print file exceeds the maximum allowable size (1GB). Please simplify the model and slice again");
|
||||
static wxString print_canceled_str = _L("Task canceled");
|
||||
static wxString upload_failed_str = _L("Failed uploading print file");
|
||||
static wxString upload_login_failed_str = _L("Wrong Access code");
|
||||
static wxString file_is_not_exists_str = _L("Print file not found. please slice again.");
|
||||
static wxString file_over_size_str = _L("The print file exceeds the maximum allowable size (1GB). Please simplify the model and slice again.");
|
||||
static wxString print_canceled_str = _L("Task canceled.");
|
||||
static wxString send_print_failed_str = _L("Failed to send the print job. Please try again.");
|
||||
static wxString upload_ftp_failed_str = _L("Failed to upload file to ftp. Please try again.");
|
||||
|
||||
static wxString desc_network_error = _L("Check the current status of the bambu server by clicking on the link above.");
|
||||
static wxString desc_file_too_large = _L("The size of the print file is too large. Please adjust the file size and try again.");
|
||||
static wxString desc_fail_not_exist = _L("Print file not found, Please slice it again and send it for printing.");
|
||||
static wxString desc_upload_ftp_failed = _L("Failed to upload print file to FTP. Please check the network status and try again.");
|
||||
|
||||
static wxString sending_over_lan_str = _L("Sending print job over LAN");
|
||||
static wxString sending_over_cloud_str = _L("Sending print job through cloud service");
|
||||
static wxString sending_over_lan_str = _L("Sending print job over LAN");
|
||||
static wxString sending_over_cloud_str = _L("Sending print job through cloud service");
|
||||
|
||||
PrintJob::PrintJob(std::shared_ptr<ProgressIndicator> pri, Plater* plater, std::string dev_id)
|
||||
: PlaterJob{ std::move(pri), plater },
|
||||
|
@ -262,7 +266,16 @@ void PrintJob::process()
|
|||
bool is_try_lan_mode = false;
|
||||
bool is_try_lan_mode_failed = false;
|
||||
|
||||
auto update_fn = [this, &is_try_lan_mode, &is_try_lan_mode_failed, &msg, &error_str, &curr_percent, &error_text, StagePercentPoint](int stage, int code, std::string info) {
|
||||
auto update_fn = [this,
|
||||
&is_try_lan_mode,
|
||||
&is_try_lan_mode_failed,
|
||||
&msg,
|
||||
&error_str,
|
||||
&curr_percent,
|
||||
&error_text,
|
||||
StagePercentPoint
|
||||
](int stage, int code, std::string info) {
|
||||
|
||||
if (stage == BBL::SendingPrintJobStage::PrintingStageCreate && !is_try_lan_mode_failed) {
|
||||
if (this->connection_type == "lan") {
|
||||
msg = _L("Sending print job over LAN");
|
||||
|
@ -318,13 +331,21 @@ void PrintJob::process()
|
|||
}
|
||||
}
|
||||
|
||||
if (code > 100 || code < 0) {
|
||||
error_text = this->get_http_error_msg(code, info);
|
||||
error_str = wxString::Format("[%s]", error_text);
|
||||
} else {
|
||||
error_str = wxEmptyString;
|
||||
//get errors
|
||||
if (code > 100 || code < 0 || stage == BBL::SendingPrintJobStage::PrintingStageERROR) {
|
||||
if (code == BAMBU_NETWORK_ERR_PRINT_WR_FILE_OVER_SIZE || code == BAMBU_NETWORK_ERR_PRINT_SP_FILE_OVER_SIZE) {
|
||||
m_plater->update_print_error_info(code, desc_file_too_large.ToStdString(), info);
|
||||
}else if (code == BAMBU_NETWORK_ERR_PRINT_WR_FILE_NOT_EXIST || code == BAMBU_NETWORK_ERR_PRINT_SP_FILE_NOT_EXIST){
|
||||
m_plater->update_print_error_info(code, desc_fail_not_exist.ToStdString(), info);
|
||||
}else if (code == BAMBU_NETWORK_ERR_PRINT_LP_UPLOAD_FTP_FAILED || code == BAMBU_NETWORK_ERR_PRINT_SG_UPLOAD_FTP_FAILED) {
|
||||
m_plater->update_print_error_info(code, desc_upload_ftp_failed.ToStdString(), info);
|
||||
}else {
|
||||
m_plater->update_print_error_info(code, desc_network_error.ToStdString(), info);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this->update_status(curr_percent, msg);
|
||||
}
|
||||
this->update_status(curr_percent, msg + error_str);
|
||||
};
|
||||
|
||||
auto cancel_fn = [this]() {
|
||||
|
@ -373,10 +394,7 @@ void PrintJob::process()
|
|||
if (result == 0) {
|
||||
params.comments = "";
|
||||
}
|
||||
else if (result == BAMBU_NETWORK_ERR_FTP_LOGIN_DENIED) {
|
||||
params.comments = "wrong_code";
|
||||
}
|
||||
else if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
|
||||
else if (result == BAMBU_NETWORK_ERR_PRINT_WR_UPLOAD_FTP_FAILED) {
|
||||
params.comments = "upload_failed";
|
||||
}
|
||||
else {
|
||||
|
@ -407,41 +425,27 @@ void PrintJob::process()
|
|||
}
|
||||
|
||||
if (result < 0) {
|
||||
if (result == BAMBU_NETWORK_ERR_FTP_LOGIN_DENIED) {
|
||||
msg_text = _L("Failed to send the print job. Please try again.");
|
||||
} if (result == BAMBU_NETWORK_ERR_FILE_NOT_EXIST) {
|
||||
curr_percent = -1;
|
||||
|
||||
if (result == BAMBU_NETWORK_ERR_PRINT_WR_FILE_NOT_EXIST || result == BAMBU_NETWORK_ERR_PRINT_SP_FILE_NOT_EXIST) {
|
||||
msg_text = file_is_not_exists_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_FILE_OVER_SIZE) {
|
||||
} else if (result == BAMBU_NETWORK_ERR_PRINT_SP_FILE_OVER_SIZE || result == BAMBU_NETWORK_ERR_PRINT_WR_FILE_OVER_SIZE) {
|
||||
msg_text = file_over_size_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_CHECK_MD5_FAILED) {
|
||||
} else if (result == BAMBU_NETWORK_ERR_PRINT_WR_CHECK_MD5_FAILED || result == BAMBU_NETWORK_ERR_PRINT_SP_CHECK_MD5_FAILED) {
|
||||
msg_text = failed_in_cloud_service_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_INVALID_PARAMS) {
|
||||
msg_text = _L("Failed to send the print job. Please try again.");
|
||||
} else if (result == BAMBU_NETWORK_ERR_PRINT_WR_GET_NOTIFICATION_TIMEOUT || result == BAMBU_NETWORK_ERR_PRINT_SP_GET_NOTIFICATION_TIMEOUT) {
|
||||
msg_text = timeout_to_upload_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_PRINT_LP_UPLOAD_FTP_FAILED || result == BAMBU_NETWORK_ERR_PRINT_SG_UPLOAD_FTP_FAILED) {
|
||||
msg_text = upload_ftp_failed_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_CANCELED) {
|
||||
msg_text = print_canceled_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_TIMEOUT) {
|
||||
msg_text = timeout_to_upload_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_INVALID_RESULT) {
|
||||
msg_text = _L("Failed to send the print job. Please try again.");
|
||||
} else if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
|
||||
msg_text = _L("Failed to send the print job. Please try again.");
|
||||
} else {
|
||||
update_status(curr_percent, failed_in_cloud_service_str);
|
||||
}
|
||||
if (!error_text.IsEmpty()) {
|
||||
curr_percent = 0;
|
||||
msg_text += wxString::Format("[%d][%s]", result, error_text);
|
||||
}
|
||||
|
||||
|
||||
if (result == BAMBU_NETWORK_ERR_INVALID_RESULT) {
|
||||
this->show_networking_test(msg_text);
|
||||
}
|
||||
else {
|
||||
update_status(curr_percent, msg_text);
|
||||
msg_text = send_print_failed_str;
|
||||
}
|
||||
|
||||
this->show_error_info(msg_text, 0, "", "");
|
||||
BOOST_LOG_TRIVIAL(error) << "print_job: failed, result = " << result;
|
||||
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "print_job: send ok.";
|
||||
wxCommandEvent* evt = new wxCommandEvent(m_print_job_completed_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue