diff --git a/Changes.md b/Changes.md index a84a25d1..3c990269 100644 --- a/Changes.md +++ b/Changes.md @@ -3,6 +3,7 @@ v1.4.18 * Ignore words in URLs in newer version of Notepad++ correctly (#67) * Fix broken rechecking on scrolling after quick edit after scrolling has been done (#222) * New words not being rechecked in case of zooming out (#225) +* Process more errors during dictionary downloading v1.4.17 * Fix interaction with some other plugins (e.g. PythonScript) (#219) diff --git a/deploy.py b/deploy.py index 51b17df7..7a65d7a7 100644 --- a/deploy.py +++ b/deploy.py @@ -85,6 +85,7 @@ def add_version_commit(): author = Signature(config['user.name'], config['user.email']) def add_version_tag (): + repo = Repository (script_dir) repo.create_tag('v{}'.format (ver_str), repo.revparse_single('HEAD').id, GIT_OBJ_COMMIT, author, 'v{}'.format (ver_str)) new_ver_is_added = False diff --git a/src/FileListProvider.h b/src/FileListProvider.h index 27b886ab..cd9f5325 100644 --- a/src/FileListProvider.h +++ b/src/FileListProvider.h @@ -31,6 +31,7 @@ enum class FileListProviderDownloadErrorType none, canceled, file_is_not_writeable, + was_not_able_to_download, }; class FileListProvider diff --git a/src/GithubFileListProvider.cpp b/src/GithubFileListProvider.cpp index 59a5a490..45f602aa 100644 --- a/src/GithubFileListProvider.cpp +++ b/src/GithubFileListProvider.cpp @@ -43,7 +43,7 @@ void GitHubFileListProvider::update_file_list() { std::wstring proxy_string; if (m_settings.data.use_proxy && m_settings.data.proxy_type == ProxyType::web_proxy) proxy_string = m_settings.data.proxy_host_name + L":" + std::to_wstring(m_settings.data.proxy_port); - using task_result_t = std::variant, Win32Exception>; + using task_result_t = std::variant, std::string /*error*/>; // TODO: possibly separate settings required for proxy connection to a struct to pass them instead of whole settings auto task = [root_path = m_root_path, proxy_string, default_timeout, settings_data = m_settings.data](Concurrency::cancellation_token token) -> task_result_t { try { @@ -60,8 +60,8 @@ void GitHubFileListProvider::update_file_list() { auto reset_secs = core_limit_data["reset"].get(); std::wstringstream wss; wss << std::put_time(std::localtime(&reset_secs), L"%H:%M"); - return Win32Exception(to_string (wstring_printf(rc_str(IDS_GITHUB_API_RATE_LIMIT_EXCEEDED_PD_PS).c_str(), core_limit_data["limit"].get(), - wss.str ().c_str ()))); + return to_string (wstring_printf(rc_str(IDS_GITHUB_API_RATE_LIMIT_EXCEEDED_PD_PS).c_str(), core_limit_data["limit"].get(), + wss.str ().c_str ())); } nlohmann::json nodes; std::wstring download_url; @@ -90,13 +90,13 @@ void GitHubFileListProvider::update_file_list() { download_url + utf8_to_wstring(node["path"].get().c_str())}); } return result; - } catch (const Win32Exception &exception) { - return exception; + } catch (const std::exception &exception) { + return exception.what (); } }; m_get_file_list_task.do_deferred(task, [this](task_result_t &&result) { std::visit(overload([](std::monostate) {}, [this](std::vector &&list) { file_list_received(std::move(list)); }, - [this](Win32Exception &&e) { error_happened(e.what()); }), + [this](std::string &&str) { error_happened(str); }), std::move(result)); }); } @@ -170,6 +170,7 @@ void GitHubFileListProvider::download_dictionary(const std::wstring &aff_filepat std::shared_ptr progress_data) { m_download_file_task.do_deferred( [=, settings_data = m_settings.data](Concurrency::cancellation_token token) { + try { std::vector downloaded_filenames; auto ret = download_dictionary_impl (token, aff_filepath, target_path, progress_data, downloaded_filenames, settings_data); if (ret != FileListProviderDownloadErrorType::none) @@ -178,6 +179,11 @@ void GitHubFileListProvider::download_dictionary(const std::wstring &aff_filepat WinApi::delete_file(file_name.c_str()); } return ret; + } + catch (const std::exception &) { + // TODO: display exception error in ui + return FileListProviderDownloadErrorType::was_not_able_to_download; + } }, [this](FileListProviderDownloadErrorType error) { file_downloaded(error); }); }