diff options
author | Max Kellermann <max@musicpd.org> | 2016-10-28 10:23:05 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-10-28 10:35:31 +0200 |
commit | 4bd67bc298fa5214eb2572d8a7c04ba0c24ac60b (patch) | |
tree | 76d67c480127f2db522fe965c8294495b256ded9 /src/db/update/InotifyUpdate.cxx | |
parent | 15607495791501bd3ec06eae366904b74352b17c (diff) |
db/update/InotifySource: migrate from class Error to C++ exceptions
Diffstat (limited to 'src/db/update/InotifyUpdate.cxx')
-rw-r--r-- | src/db/update/InotifyUpdate.cxx | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/db/update/InotifyUpdate.cxx b/src/db/update/InotifyUpdate.cxx index cb619b404..7d2e20ad6 100644 --- a/src/db/update/InotifyUpdate.cxx +++ b/src/db/update/InotifyUpdate.cxx @@ -25,7 +25,6 @@ #include "storage/StorageInterface.hxx" #include "fs/AllocatedPath.hxx" #include "fs/FileInfo.hxx" -#include "util/Error.hxx" #include "Log.hxx" #include <string> @@ -157,7 +156,6 @@ static void recursive_watch_subdirectories(WatchDirectory *directory, const AllocatedPath &path_fs, unsigned depth) { - Error error; DIR *dir; struct dirent *ent; @@ -187,22 +185,23 @@ recursive_watch_subdirectories(WatchDirectory *directory, AllocatedPath::Build(path_fs, ent->d_name); FileInfo fi; - if (!GetFileInfo(child_path_fs, fi, error)) { - LogError(error); - error.Clear(); + try { + fi = FileInfo(child_path_fs); + } catch (const std::runtime_error &e) { + LogError(e); continue; } if (!fi.IsDirectory()) continue; - ret = inotify_source->Add(child_path_fs.c_str(), IN_MASK, - error); - if (ret < 0) { - FormatError(error, + try { + ret = inotify_source->Add(child_path_fs.c_str(), + IN_MASK); + } catch (const std::runtime_error &e) { + FormatError(e, "Failed to register %s", child_path_fs.c_str()); - error.Clear(); continue; } @@ -299,20 +298,22 @@ mpd_inotify_init(EventLoop &loop, Storage &storage, UpdateService &update, return; } - Error error; - inotify_source = InotifySource::Create(loop, - mpd_inotify_callback, nullptr, - error); - if (inotify_source == nullptr) { - LogError(error); + try { + inotify_source = new InotifySource(loop, + mpd_inotify_callback, + nullptr); + } catch (const std::runtime_error &e) { + LogError(e); return; } inotify_max_depth = max_depth; - int descriptor = inotify_source->Add(path.c_str(), IN_MASK, error); - if (descriptor < 0) { - LogError(error); + int descriptor; + try { + descriptor = inotify_source->Add(path.c_str(), IN_MASK); + } catch (const std::runtime_error &e) { + LogError(e); delete inotify_source; inotify_source = nullptr; return; |