From c1b2c18bb0c034ab67377827b27536dad5094fd5 Mon Sep 17 00:00:00 2001 From: Koichi Nakashima Date: Thu, 14 Nov 2019 02:43:49 +0900 Subject: [PATCH] elsi: Fix error when explorer does not exist --- src/shell.cpp | 8 ++++---- src/util.cpp | 8 ++++++++ src/util.h | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/shell.cpp b/src/shell.cpp index 05d28ae..0c48b2c 100644 --- a/src/shell.cpp +++ b/src/shell.cpp @@ -65,9 +65,7 @@ namespace ebridge { std::wstring Shell::GetWorkingDirectory() { auto explorer = GetActiveExplorer(); if (!explorer.Exists()) { - throw std::runtime_error( - "Explorer is not running. " - "(Is \"Launch folder windows in a separete process\" enabled?)"); + throw util::active_explorer_not_found(); } return explorer.GetPath(); } @@ -144,7 +142,9 @@ namespace ebridge { std::vector Shell::SelectedItems() { auto explorer = GetActiveExplorer(); - + if (!explorer.Exists()) { + throw util::active_explorer_not_found(); + } return explorer.SelectedItems(); } diff --git a/src/util.cpp b/src/util.cpp index e40c2cf..b95e0f9 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -4,6 +4,14 @@ #include #include "util.h" +util::active_explorer_not_found::active_explorer_not_found() : + std::runtime_error( + "Explorer is not running. " + "(Is \"Launch folder windows in a separete process\" enabled?)" + ) +{ +} + std::wstring util::getenv(std::wstring name, std::wstring default_value) { wchar_t* buf = nullptr; diff --git a/src/util.h b/src/util.h index 495e1d1..d8072db 100644 --- a/src/util.h +++ b/src/util.h @@ -3,6 +3,11 @@ namespace util { class silent_error {}; + class active_explorer_not_found : public std::runtime_error + { + public: + active_explorer_not_found(); + }; std::wstring getenv(std::wstring name, std::wstring default_value = L""); std::wstring normalize_path_separator(std::wstring path);