Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Dmitri Naumov
ogs
Commits
614c77f4
Commit
614c77f4
authored
8 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[BL] assert that ConfigTree dtor is nothrow
parent
70d9bd96
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BaseLib/ConfigTree.cpp
+24
-1
24 additions, 1 deletion
BaseLib/ConfigTree.cpp
BaseLib/ConfigTree.h
+5
-1
5 additions, 1 deletion
BaseLib/ConfigTree.h
with
29 additions
and
2 deletions
BaseLib/ConfigTree.cpp
+
24
−
1
View file @
614c77f4
...
...
@@ -9,6 +9,7 @@
#include
"ConfigTree.h"
#include
<forward_list>
#include
<logog/include/logog.hpp>
#include
"Error.h"
...
...
@@ -18,6 +19,10 @@
template
class
boost
::
property_tree
::
basic_ptree
<
std
::
string
,
std
::
string
,
std
::
less
<
std
::
string
>
>
;
//! Collects swallowed error messages raised by the check during destruction of
//! ConfigTree instances.
static
std
::
forward_list
<
std
::
string
>
configtree_destructor_error_messages
;
namespace
BaseLib
{
...
...
@@ -65,8 +70,11 @@ ConfigTree(ConfigTree && other)
ConfigTree
::~
ConfigTree
()
{
if
(
!
std
::
uncaught_exception
())
try
{
checkAndInvalidate
();
}
catch
(
std
::
exception
&
e
)
{
configtree_destructor_error_messages
.
push_front
(
e
.
what
());
}
}
ConfigTree
&
...
...
@@ -220,6 +228,21 @@ void ConfigTree::onwarning(const std::string& filename, const std::string& path,
filename
.
c_str
(),
path
.
c_str
(),
message
.
c_str
());
}
void
ConfigTree
::
assertNoSwallowedErrors
()
{
if
(
configtree_destructor_error_messages
.
empty
())
return
;
ERR
(
"ConfigTree: There have been errors when parsing the configuration "
"file(s):"
);
for
(
auto
const
&
msg
:
configtree_destructor_error_messages
)
{
ERR
(
"%s"
,
msg
.
c_str
());
}
OGS_FATAL
(
"There have been errors when parsing the configuration file(s)."
);
}
std
::
string
ConfigTree
::
shortString
(
const
std
::
string
&
s
)
{
const
std
::
size_t
maxlen
=
100
;
...
...
This diff is collapsed.
Click to expand it.
BaseLib/ConfigTree.h
+
5
−
1
View file @
614c77f4
...
...
@@ -493,6 +493,8 @@ public:
//! The destructor performs the check if all nodes at the current level of the tree
//! have been read.
//! Errors raised by the check are swallowed. Use assertNoSwallowedErrors()
//! manually to check for those.
~
ConfigTree
();
//! Default error callback function
...
...
@@ -505,6 +507,9 @@ public:
static
void
onwarning
(
std
::
string
const
&
filename
,
std
::
string
const
&
path
,
std
::
string
const
&
message
);
//! Asserts that there have not been any errors reported in the destructor.
static
void
assertNoSwallowedErrors
();
private
:
//! Default implementation of reading a value of type T.
template
<
typename
T
>
boost
::
optional
<
T
>
...
...
@@ -514,7 +519,6 @@ private:
template
<
typename
T
>
boost
::
optional
<
std
::
vector
<
T
>>
getConfigParameterOptionalImpl
(
std
::
string
const
&
param
,
std
::
vector
<
T
>*
)
const
;
private
:
struct
CountType
{
int
count
;
...
...
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