mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
config: produce error instead fs::exists exceptions (#177)
This commit is contained in:
parent
374d6e2a9d
commit
f4abf5902f
1 changed files with 8 additions and 4 deletions
|
@ -26,8 +26,10 @@ static Hyprlang::CParseResult handleWallpaper(const char* C, const char* V) {
|
||||||
WALLPAPER = std::string(ENVHOME) + WALLPAPER.substr(1);
|
WALLPAPER = std::string(ENVHOME) + WALLPAPER.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!std::filesystem::exists(WALLPAPER)) {
|
std::error_code ec;
|
||||||
result.setError("wallpaper failed (no such file)");
|
|
||||||
|
if (!std::filesystem::exists(WALLPAPER, ec)) {
|
||||||
|
result.setError((std::string{"wallpaper failed ("} + (ec ? ec.message() : std::string{"no such file"}) + std::string{": "} + WALLPAPER + std::string{")"}).c_str());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +69,11 @@ static Hyprlang::CParseResult handlePreload(const char* C, const char* V) {
|
||||||
WALLPAPER = std::string(ENVHOME) + WALLPAPER.substr(1);
|
WALLPAPER = std::string(ENVHOME) + WALLPAPER.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!std::filesystem::exists(WALLPAPER)) {
|
std::error_code ec;
|
||||||
|
|
||||||
|
if (!std::filesystem::exists(WALLPAPER, ec)) {
|
||||||
Hyprlang::CParseResult result;
|
Hyprlang::CParseResult result;
|
||||||
result.setError((std::string{"no such file: "} + WALLPAPER).c_str());
|
result.setError(((ec ? ec.message() : std::string{"no such file"}) + std::string{": "} + WALLPAPER).c_str());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue