summaryrefslogtreecommitdiff
path: root/backend/genesys/error.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-24 18:45:55 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-08-24 18:45:55 +0200
commita77bc1fcbdf83cfdac9570c0a0ac886b5534c90f (patch)
treed839746371ecb8ed64ac81d2e37c11fcd25a00ac /backend/genesys/error.h
parent787fb1d54ec9ee5fb941ae897fb201feb9cb2fd1 (diff)
parent2b3e02411ecc09e7d41741b5587655c9b2f955b7 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'backend/genesys/error.h')
-rw-r--r--backend/genesys/error.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/backend/genesys/error.h b/backend/genesys/error.h
index 5aba8cf..26235dd 100644
--- a/backend/genesys/error.h
+++ b/backend/genesys/error.h
@@ -137,7 +137,6 @@ private:
unsigned num_exceptions_on_enter_ = 0;
};
-
#if defined(__GNUC__) || defined(__clang__)
#define GENESYS_CURRENT_FUNCTION __PRETTY_FUNCTION__
#elif defined(__FUNCSIG__)
@@ -149,6 +148,8 @@ private:
#define DBG_HELPER(var) DebugMessageHelper var(GENESYS_CURRENT_FUNCTION)
#define DBG_HELPER_ARGS(var, ...) DebugMessageHelper var(GENESYS_CURRENT_FUNCTION, __VA_ARGS__)
+bool dbg_log_image_data();
+
template<class F>
SANE_Status wrap_exceptions_to_status_code(const char* func, F&& function)
{
@@ -172,6 +173,27 @@ SANE_Status wrap_exceptions_to_status_code(const char* func, F&& function)
}
template<class F>
+SANE_Status wrap_exceptions_to_status_code_return(const char* func, F&& function)
+{
+ try {
+ return function();
+ } catch (const SaneException& exc) {
+ DBG(DBG_error, "%s: got error: %s\n", func, exc.what());
+ return exc.status();
+ } catch (const std::bad_alloc& exc) {
+ (void) exc;
+ DBG(DBG_error, "%s: failed to allocate memory\n", func);
+ return SANE_STATUS_NO_MEM;
+ } catch (const std::exception& exc) {
+ DBG(DBG_error, "%s: got uncaught exception: %s\n", func, exc.what());
+ return SANE_STATUS_INVAL;
+ } catch (...) {
+ DBG(DBG_error, "%s: got unknown uncaught exception\n", func);
+ return SANE_STATUS_INVAL;
+ }
+}
+
+template<class F>
void catch_all_exceptions(const char* func, F&& function)
{
try {