Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
e70a83bd
Commit
e70a83bd
authored
May 29, 2019
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add error handling for config file option
parent
b49fc255
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
7 deletions
+20
-7
libcaf_core/caf/actor_system_config.hpp
libcaf_core/caf/actor_system_config.hpp
+1
-1
libcaf_core/caf/sec.hpp
libcaf_core/caf/sec.hpp
+2
-0
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+16
-6
libcaf_core/src/sec.cpp
libcaf_core/src/sec.cpp
+1
-0
No files found.
libcaf_core/caf/actor_system_config.hpp
View file @
e70a83bd
...
...
@@ -342,7 +342,7 @@ private:
actor_system_config
&
set_impl
(
string_view
name
,
config_value
value
);
void
extract_config_file_path
(
string_list
&
args
);
error
extract_config_file_path
(
string_list
&
args
);
/// Adjusts the content of the configuration, e.g., for ensuring backwards
/// compatibility with older options.
...
...
libcaf_core/caf/sec.hpp
View file @
e70a83bd
...
...
@@ -114,6 +114,8 @@ enum class sec : uint8_t {
bad_function_call
=
40
,
/// Feature is disabled in the actor system config.
feature_disabled
,
/// Failed to open file.
cannot_open_file
,
};
/// @relates sec
...
...
libcaf_core/src/actor_system_config.cpp
View file @
e70a83bd
...
...
@@ -35,6 +35,12 @@
namespace
caf
{
namespace
{
constexpr
const
char
*
default_config_file
=
"caf-application.ini"
;
}
// namespace anonymous
actor_system_config
::~
actor_system_config
()
{
// nop
}
...
...
@@ -45,7 +51,7 @@ actor_system_config::~actor_system_config() {
actor_system_config
::
actor_system_config
()
:
cli_helptext_printed
(
false
),
slave_mode
(
false
),
config_file_path
(
"caf-application.ini"
),
config_file_path
(
default_config_file
),
slave_mode_fun
(
nullptr
)
{
// add `vector<T>` and `stream<T>` for each statically known type
add_message_type_impl
<
stream
<
actor
>>
(
"stream<@actor>"
);
...
...
@@ -287,8 +293,11 @@ error actor_system_config::parse(string_list args, const char* ini_file_cstr) {
if
(
ini_file_cstr
!=
nullptr
)
config_file_path
=
ini_file_cstr
;
// CLI arguments always win.
extract_config_file_path
(
args
);
if
(
auto
err
=
extract_config_file_path
(
args
))
return
err
;
std
::
ifstream
ini
{
config_file_path
};
if
(
config_file_path
!=
default_config_file
&&
!
ini
)
return
make_error
(
sec
::
cannot_open_file
,
config_file_path
);
return
parse
(
std
::
move
(
args
),
ini
);
}
...
...
@@ -367,22 +376,23 @@ std::string actor_system_config::render_pec(uint8_t x, atom_value,
meta
::
omittable_if_empty
(),
xs
);
}
void
actor_system_config
::
extract_config_file_path
(
string_list
&
args
)
{
error
actor_system_config
::
extract_config_file_path
(
string_list
&
args
)
{
auto
ptr
=
custom_options_
.
qualified_name_lookup
(
"global.config-file"
);
CAF_ASSERT
(
ptr
!=
nullptr
);
string_list
::
iterator
i
;
string_view
path
;
std
::
tie
(
i
,
path
)
=
find_by_long_name
(
*
ptr
,
args
.
begin
(),
args
.
end
());
if
(
i
==
args
.
end
())
return
;
return
none
;
if
(
path
.
empty
())
{
args
.
erase
(
i
);
return
;
return
make_error
(
pec
::
missing_argument
,
std
::
string
{
*
i
})
;
}
auto
evalue
=
ptr
->
parse
(
path
);
if
(
!
evalue
)
return
;
return
std
::
move
(
evalue
.
error
())
;
ptr
->
store
(
*
evalue
);
return
none
;
}
error
actor_system_config
::
adjust_content
()
{
...
...
libcaf_core/src/sec.cpp
View file @
e70a83bd
...
...
@@ -67,6 +67,7 @@ const char* sec_strings[] = {
"unhandled_stream_error"
,
"bad_function_call"
,
"feature_disabled"
,
"cannot_open_file"
,
};
}
// namespace <anonymous>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment