From 937004515a586b039448bd0b2316918be9590ab4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Milk?= <rene.milk@wwu.de>
Date: Wed, 31 Jan 2018 17:05:30 +0100
Subject: [PATCH] [exceptions] adds a handy new throw macro

This allows to refactor all those
```if(foo) {
throw bla;
}
```
blocks into ```DUNE_THROW_IF(foo, bla, "")```
---
 dune/xt/common/exceptions.hh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/dune/xt/common/exceptions.hh b/dune/xt/common/exceptions.hh
index bd18bfb87..72bd5459a 100644
--- a/dune/xt/common/exceptions.hh
+++ b/dune/xt/common/exceptions.hh
@@ -70,6 +70,10 @@ if (a.size() != b.size())
   } while (0)
 // DUNE_THROW
 
+#define DUNE_THROW_IF(condition, E, m)                                                                                 \
+  if (condition) {                                                                                                     \
+    DUNE_THROW(E, m);                                                                                                  \
+  }
 
 namespace Dune {
 namespace XT {
-- 
GitLab