summaryrefslogtreecommitdiff
path: root/lib/status_handler_impl.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:19:14 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:19:14 +0200
commit01eb8253196672c969a39587e90b49321a182428 (patch)
tree4a3b71d7913de519744466c9227fda6461c4f0b5 /lib/status_handler_impl.h
parent5.0 (diff)
downloadFreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.gz
FreeFileSync-01eb8253196672c969a39587e90b49321a182428.tar.bz2
FreeFileSync-01eb8253196672c969a39587e90b49321a182428.zip
5.1
Diffstat (limited to 'lib/status_handler_impl.h')
-rw-r--r--lib/status_handler_impl.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/status_handler_impl.h b/lib/status_handler_impl.h
new file mode 100644
index 00000000..7141d75c
--- /dev/null
+++ b/lib/status_handler_impl.h
@@ -0,0 +1,34 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved *
+// **************************************************************************
+
+#ifndef STATUSHANDLER_IMPL_H_INCLUDED
+#define STATUSHANDLER_IMPL_H_INCLUDED
+
+#include <zen/file_error.h>
+#include "status_handler.h"
+
+template <typename Function> inline
+bool tryReportingError(Function cmd, ProcessCallback& handler) //return "true" on success, "false" if error was ignored
+{
+ for (;;)
+ try
+ {
+ cmd(); //throw FileError
+ return true;
+ }
+ catch (zen::FileError& error)
+ {
+ switch (handler.reportError(error.toString())) //may throw!
+ {
+ case ProcessCallback::IGNORE_ERROR:
+ return false;
+ case ProcessCallback::RETRY:
+ break; //continue with loop
+ }
+ }
+}
+
+#endif //STATUSHANDLER_IMPL_H_INCLUDED
bgstack15