Skip to content

Commit

Permalink
elsi: Fix error when explorer does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ko1nksm committed Nov 13, 2019
1 parent 42b58e8 commit c1b2c18
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -144,7 +142,9 @@ namespace ebridge {

std::vector<std::wstring> Shell::SelectedItems() {
auto explorer = GetActiveExplorer();

if (!explorer.Exists()) {
throw util::active_explorer_not_found();
}
return explorer.SelectedItems();
}

Expand Down
8 changes: 8 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
#include <io.h>
#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;
Expand Down
5 changes: 5 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c1b2c18

Please sign in to comment.