Add conditional exception-throwing macros for error handling 01/136901/2
authorMu-Woong Lee <muwoong.lee@samsung.com>
Mon, 3 Jul 2017 11:11:47 +0000 (20:11 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Tue, 4 Jul 2017 04:39:53 +0000 (04:39 +0000)
Change-Id: I4d1c6334b882a53e8ae4dad5821f32ad796dffbb
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/ContextTypes.h

index 2fdbaf0..13150f2 100644 (file)
 #define IF_FAIL_CATCH(cond) \
        do { if (!(cond)) { goto CATCH; } } while (0)
 
-#define IS_FAILED(X) ((X) != ERR_NONE)
+#define IF_FAIL_THROW_TAG(cond, excp, tag, fmt, arg...) \
+       do { if (!(cond)) { tag(fmt, ##arg); throw excp; } } while (0)
+
+#define IF_FAIL_THROW(cond, excp) \
+       do { if (!(cond)) { throw excp; } } while (0)
+
+#define IS_FAILED(X) ((X) < 0)
+
+#define IS_SUCCESS(X) ((X) >= 0)
 
 #define HANDLE_GERROR(Err) \
        do { if ((Err)) { _E("GError: %s", Err->message); g_error_free(Err); Err = NULL; } } while (0)