summaryrefslogtreecommitdiff
path: root/test/run_inotify.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-10-28 10:23:05 +0200
committerMax Kellermann <max@musicpd.org>2016-10-28 10:35:31 +0200
commit4bd67bc298fa5214eb2572d8a7c04ba0c24ac60b (patch)
tree76d67c480127f2db522fe965c8294495b256ded9 /test/run_inotify.cxx
parent15607495791501bd3ec06eae366904b74352b17c (diff)
db/update/InotifySource: migrate from class Error to C++ exceptions
Diffstat (limited to 'test/run_inotify.cxx')
-rw-r--r--test/run_inotify.cxx24
1 files changed, 6 insertions, 18 deletions
diff --git a/test/run_inotify.cxx b/test/run_inotify.cxx
index 4f09c4638..505950848 100644
--- a/test/run_inotify.cxx
+++ b/test/run_inotify.cxx
@@ -21,7 +21,6 @@
#include "ShutdownHandler.hxx"
#include "db/update/InotifySource.hxx"
#include "event/Loop.hxx"
-#include "util/Error.hxx"
#include "Log.hxx"
#include <sys/inotify.h>
@@ -41,7 +40,7 @@ my_inotify_callback(gcc_unused int wd, unsigned mask,
}
int main(int argc, char **argv)
-{
+try {
const char *path;
if (argc != 2) {
@@ -54,24 +53,13 @@ int main(int argc, char **argv)
EventLoop event_loop;
const ShutdownHandler shutdown_handler(event_loop);
- Error error;
- InotifySource *source = InotifySource::Create(event_loop,
- my_inotify_callback,
- nullptr, error);
- if (source == NULL) {
- LogError(error);
- return EXIT_FAILURE;
- }
-
- int descriptor = source->Add(path, IN_MASK, error);
- if (descriptor < 0) {
- delete source;
- LogError(error);
- return EXIT_FAILURE;
- }
+ InotifySource source(event_loop, my_inotify_callback, nullptr);
+ source.Add(path, IN_MASK);
event_loop.Run();
- delete source;
return EXIT_SUCCESS;
+} catch (const std::runtime_error &e) {
+ LogError(e);
+ return EXIT_FAILURE;
}