Skip to content
Snippets Groups Projects
Commit 286f680e authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[exceptions] only use coloring output if terminal supports it, fixes #5

parent 055e7c6f
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <dune/common/exceptions.hh> #include <dune/common/exceptions.hh>
#include <dune/common/parallel/mpihelper.hh> #include <dune/common/parallel/mpihelper.hh>
#include <dune/xt/common/color.hh>
#include <dune/xt/common/deprecated.hh> #include <dune/xt/common/deprecated.hh>
#ifdef DUNE_THROW #ifdef DUNE_THROW
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
#if HAVE_TBB #if HAVE_TBB
namespace tbb { namespace tbb {
class tbb_exception; class tbb_exception;
} }
...@@ -49,9 +51,9 @@ if (a.size() != b.size()) ...@@ -49,9 +51,9 @@ if (a.size() != b.size())
*/ */
#define DUNE_THROW(E, m) \ #define DUNE_THROW(E, m) \
do { \ do { \
const std::string th__red = "\033[31m"; \ const std::string th__red = Dune::XT::Common::terminal_supports_color() ? "\033[31m" : ""; \
const std::string th__brown = "\033[33m"; \ const std::string th__brown = Dune::XT::Common::terminal_supports_color() ? "\033[33m" : ""; \
const std::string th__clear = "\033[0m"; \ const std::string th__clear = Dune::XT::Common::terminal_supports_color() ? "\033[0m" : ""; \
E th__ex; \ E th__ex; \
std::ostringstream th__msg; \ std::ostringstream th__msg; \
th__msg << m; \ th__msg << m; \
...@@ -72,6 +74,7 @@ if (a.size() != b.size()) ...@@ -72,6 +74,7 @@ if (a.size() != b.size())
} while (0) } while (0)
// DUNE_THROW // DUNE_THROW
#define DUNE_THROW_IF(condition, E, m) \ #define DUNE_THROW_IF(condition, E, m) \
do { \ do { \
if (condition) { \ if (condition) { \
...@@ -79,6 +82,7 @@ if (a.size() != b.size()) ...@@ -79,6 +82,7 @@ if (a.size() != b.size())
} \ } \
} while (0) } while (0)
namespace Dune { namespace Dune {
namespace XT { namespace XT {
namespace Common { namespace Common {
...@@ -146,7 +150,9 @@ class dependency_missing : public Dune::Exception ...@@ -146,7 +150,9 @@ class dependency_missing : public Dune::Exception
int handle_exception(const Dune::Exception& exp); int handle_exception(const Dune::Exception& exp);
int handle_exception(const std::exception& exp); int handle_exception(const std::exception& exp);
#if HAVE_TBB #if HAVE_TBB
int handle_exception(const tbb::tbb_exception& exp); int handle_exception(const tbb::tbb_exception& exp);
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment