From 89a217830872e5f349ebf60193ca54eaeaf86425 Mon Sep 17 00:00:00 2001 From: Alexis Maiquez Date: Tue, 12 Dec 2023 02:13:06 +0100 Subject: [PATCH] CDirectory should not use sLog for errors Signed-off-by: Alexis Maiquez --- src/WallpaperEngine/Application/CWallpaperApplication.cpp | 5 +++-- src/WallpaperEngine/Assets/CDirectory.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/WallpaperEngine/Application/CWallpaperApplication.cpp b/src/WallpaperEngine/Application/CWallpaperApplication.cpp index 113a488f..e86d5178 100644 --- a/src/WallpaperEngine/Application/CWallpaperApplication.cpp +++ b/src/WallpaperEngine/Application/CWallpaperApplication.cpp @@ -7,6 +7,7 @@ #include "WallpaperEngine/Logging/CLog.h" #include "WallpaperEngine/Render/CRenderContext.h" #include "WallpaperEngine/Application/CApplicationState.h" +#include "WallpaperEngine/Assets/CAssetLoadException.h" #include "WallpaperEngine/Audio/Drivers/Detectors/CPulseAudioPlayingDetector.h" #include "WallpaperEngine/Input/Drivers/CGLFWMouseInput.h" @@ -54,7 +55,7 @@ namespace WallpaperEngine::Application { container.add (new CDirectory ("../share/")); } - catch (std::runtime_error& ex) + catch (CAssetLoadException& ex) { relative = false; } @@ -63,7 +64,7 @@ namespace WallpaperEngine::Application { container.add (new CDirectory (DATADIR)); } - catch (std::runtime_error& ex) + catch (CAssetLoadException& ex) { absolute = false; } diff --git a/src/WallpaperEngine/Assets/CDirectory.cpp b/src/WallpaperEngine/Assets/CDirectory.cpp index d66cb25c..f80181ac 100644 --- a/src/WallpaperEngine/Assets/CDirectory.cpp +++ b/src/WallpaperEngine/Assets/CDirectory.cpp @@ -15,10 +15,10 @@ CDirectory::CDirectory (std::filesystem::path basepath) : struct stat buffer {}; if (stat (this->m_basepath.c_str (), &buffer) != 0) - sLog.exception ("Cannot find ", this->m_basepath, ". This folder is required for wallpaper engine to work"); + throw CAssetLoadException (this->m_basepath, "Cannot find directory"); if (!S_ISDIR(buffer.st_mode)) - sLog.exception ("Cannot find ", this->m_basepath, ". There's an assets file in it's place"); + throw CAssetLoadException (this->m_basepath, "Expected directory but found a file"); } CDirectory::~CDirectory ()