Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-xt
Commits
f970ef13
Commit
f970ef13
authored
11 years ago
by
Dr. Felix Tobias Schindler
Browse files
Options
Downloads
Patches
Plain Diff
[common.exceptions] added functionality from dune-pymor
* there is now DUNE_THROW_COLORFULLY :)
parent
e367c98b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/stuff/common/exceptions.hh
+69
-0
69 additions, 0 deletions
dune/stuff/common/exceptions.hh
with
69 additions
and
0 deletions
dune/stuff/common/exceptions.hh
0 → 100644
+
69
−
0
View file @
f970ef13
// This file is part of the dune-stuff project:
// https://users.dune-project.org/projects/dune-stuff/
// Copyright Holders: Felix Albrecht, Rene Milk
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
#ifndef DUNE_STUFF_COMMON_EXCEPTIONS_HH
#define DUNE_STUFF_COMMON_EXCEPTIONS_HH
#include
<dune/common/exceptions.hh>
#include
<dune/stuff/common/color.hh>
/**
* \brief Macro to throw a colorfull exception.
*
* Example:
\code
#include <dune/stuff/common/exceptions.hh>
if (a.size() != b.size())
DUNE_THROW_COLORFULLY(Exception::shapes_do_not_match,
"size of a (" << a.size() << ") does not match the size of b (" << b.size() << ")!");
\endcode
* This macro is essentially copied from dune-common with added color functionality.
* \param E Exception class, derived from Dune::Exception.
* \param m Message in ostream notation.
* \see DUNE_THROW, Dune::Exception
*/
#define DUNE_THROW_COLORFULLY(E, m) \
do { \
E th__ex; \
std::ostringstream th__msg; \
th__msg << m; \
std::ostringstream th__out; \
th__out << Dune::Stuff::Common::Colors::red << #E << "\033[0m\n"; \
th__out << Dune::Stuff::Common::Colors::red << "[\033[0m"; \
th__out << __func__; \
th__out << Dune::Stuff::Common::Colors::red << "|\033[0m"; \
th__out << __FILE__ << Dune::Stuff::Common::Colors::red << ":" << __LINE__ << "]\033[0m"; \
if (!th__msg.str().empty()) \
th__out << "\n" << Dune::Stuff::Common::Colors::red << "=>\033[0m " << th__msg.str(); \
th__ex.message(th__out.str()); \
throw th__ex; \
} while (0)
// DUNE_THROW_COLORFULLY
namespace
Dune
{
namespace
Stuff
{
namespace
Exception
{
class
CRTP_check_failed
:
public
Dune
::
Exception
{
};
class
shapes_do_not_match
:
public
Dune
::
Exception
{
};
class
index_out_of_range
:
public
Dune
::
Exception
{
};
}
// namespace Exception
}
// namespace Stuff
}
// namespace Dune
#endif // DUNE_STUFF_COMMON_EXCEPTIONS_HH
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment