From 0cd2c51138a4e5ebc3fc6e7fb4c5435a79a9f69c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 8 Jun 2025 00:31:14 +0200 Subject: Better handling / presentation of network errors during uploads. --- src/lib/curl_uploader.cc | 5 +++-- src/lib/job.cc | 6 ++++++ src/lib/scp_uploader.cc | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lib/curl_uploader.cc b/src/lib/curl_uploader.cc index bdbdb098f..18d4f9166 100644 --- a/src/lib/curl_uploader.cc +++ b/src/lib/curl_uploader.cc @@ -26,6 +26,7 @@ #include "cross.h" #include "compose.hpp" #include "dcpomatic_assert.h" +#include #include #include "i18n.h" @@ -121,8 +122,8 @@ CurlUploader::upload_file(boost::filesystem::path from, boost::filesystem::path auto const r = curl_easy_perform(_curl); if (r != CURLE_OK) { throw NetworkError( - String::compose(_("Could not write to remote file %1"), to.generic_string()), - string(curl_easy_strerror(r)) + _("Could not write to remote file"), + fmt::format(_("File: {} error: {}"), to.generic_string(), string(curl_easy_strerror(r))) ); } diff --git a/src/lib/job.cc b/src/lib/job.cc index 568a06d94..ff19c5aad 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -258,6 +258,12 @@ Job::run_wrapper () set_progress(1); set_state(FINISHED_ERROR); + } catch (NetworkError& e) { + + set_error(e.summary(), e.detail().get_value_or("")); + set_progress(1); + set_state(FINISHED_ERROR); + } catch (std::exception& e) { set_error ( diff --git a/src/lib/scp_uploader.cc b/src/lib/scp_uploader.cc index 2735f0155..a81ddbc69 100644 --- a/src/lib/scp_uploader.cc +++ b/src/lib/scp_uploader.cc @@ -135,7 +135,10 @@ LIBDCP_DISABLE_WARNINGS int const r = ssh_scp_write(_scp, buffer.data(), t); LIBDCP_ENABLE_WARNINGS if (r != SSH_OK) { - throw NetworkError(String::compose(_("Could not write to remote file (%1)"), ssh_get_error(_session))); + throw NetworkError( + _("Could not write to remote file"), + string(ssh_get_error(_session)) + ); } to_do -= t; transferred += t; -- cgit v1.2.3