mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-10 05:52:44 +00:00
CrealityPrint: propagate start_print() errors to caller
Change start_print() from void to bool with a wxString& msg out-parameter, matching the error handling pattern used by Duet, MKS, ESP3D and Flashforge. On failure, the error message is now reported to the user via error_fn instead of being silently swallowed. Use BOOST_LOG_TRIVIAL for logging instead of std::cerr. Signed-off-by: Igor Mammedov <niallain@gmail.com>
This commit is contained in:
@@ -137,7 +137,11 @@ bool CrealityPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn,
|
||||
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: File uploaded: HTTP %2%: %3%") % name % status % body;
|
||||
|
||||
if (upload_data.post_action == PrintHostPostUploadAction::StartPrint) {
|
||||
start_print(safe_filename(upload_filename.string()));
|
||||
wxString errormsg;
|
||||
if (!start_print(errormsg, safe_filename(upload_filename.string()))) {
|
||||
error_fn(std::move(errormsg));
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
})
|
||||
.on_error([&](std::string body, std::string error, unsigned status) {
|
||||
@@ -182,7 +186,7 @@ std::string CrealityPrint::safe_filename(const std::string &filename) const
|
||||
return safe_filename;
|
||||
}
|
||||
|
||||
void CrealityPrint::start_print(const std::string &filename) const
|
||||
bool CrealityPrint::start_print(wxString &msg, const std::string &filename) const
|
||||
{
|
||||
try {
|
||||
std::string host = Http::get_host_from_url(m_host);
|
||||
@@ -225,10 +229,12 @@ void CrealityPrint::start_print(const std::string &filename) const
|
||||
ws.read(buffer);
|
||||
|
||||
ws.close(websocket::close_code::normal);
|
||||
return true;
|
||||
} catch(std::exception const& e) {
|
||||
std::cerr << "Error: " << e.what() << std::endl;
|
||||
BOOST_LOG_TRIVIAL(error) << "CrealityPrint: Error starting print: " << e.what();
|
||||
msg = wxString::FromUTF8(e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
bool m_ssl_revoke_best_effort;
|
||||
|
||||
std::string make_url(const std::string& path) const;
|
||||
void start_print(const std::string& path) const;
|
||||
bool start_print(wxString& msg, const std::string& path) const;
|
||||
std::string safe_filename(const std::string& filename) const;
|
||||
};
|
||||
} // namespace Slic3r
|
||||
|
||||
Reference in New Issue
Block a user