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
277584d4
Commit
277584d4
authored
Feb 25, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deliver errors if requests fail with exceptions
(cherry picked from commit
7b5919d7
)
parent
0565fe47
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
4 deletions
+31
-4
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+10
-4
libcaf_core/test/mixin/requester.cpp
libcaf_core/test/mixin/requester.cpp
+21
-0
No files found.
libcaf_core/src/scheduled_actor.cpp
View file @
277584d4
...
...
@@ -791,6 +791,14 @@ auto scheduled_actor::activate(execution_unit* ctx, mailbox_element& x)
auto
scheduled_actor
::
reactivate
(
mailbox_element
&
x
)
->
activation_result
{
CAF_LOG_TRACE
(
CAF_ARG
(
x
));
#ifndef CAF_NO_EXCEPTIONS
auto
handle_exception
=
[
&
](
std
::
exception_ptr
eptr
)
{
auto
err
=
call_handler
(
exception_handler_
,
this
,
eptr
);
if
(
x
.
mid
.
is_request
())
{
auto
rp
=
make_response_promise
();
rp
.
deliver
(
err
);
}
quit
(
std
::
move
(
err
));
};
try
{
#endif // CAF_NO_EXCEPTIONS
switch
(
consume
(
x
))
{
...
...
@@ -810,12 +818,10 @@ auto scheduled_actor::reactivate(mailbox_element& x) -> activation_result {
}
catch
(
std
::
exception
&
e
)
{
CAF_LOG_INFO
(
"actor died because of an exception, what: "
<<
e
.
what
());
static_cast
<
void
>
(
e
);
// keep compiler happy when not logging
auto
eptr
=
std
::
current_exception
();
quit
(
call_handler
(
exception_handler_
,
this
,
eptr
));
handle_exception
(
std
::
current_exception
());
}
catch
(...)
{
CAF_LOG_INFO
(
"actor died because of an unknown exception"
);
auto
eptr
=
std
::
current_exception
();
quit
(
call_handler
(
exception_handler_
,
this
,
eptr
));
handle_exception
(
std
::
current_exception
());
}
finalize
();
return
activation_result
::
terminated
;
...
...
libcaf_core/test/mixin/requester.cpp
View file @
277584d4
...
...
@@ -150,4 +150,25 @@ CAF_TEST(delegated request with integer result) {
CAF_CHECK_EQUAL
(
*
result
,
3
);
}
#ifndef CAF_NO_EXCEPTIONS
CAF_TEST
(
exceptions
while
processing
requests
trigger
error
messages
)
{
auto
worker
=
sys
.
spawn
([]
{
return
behavior
{
[](
int
)
{
throw
std
::
runtime_error
(
""
);
},
};
});
run
();
auto
client
=
sys
.
spawn
([
worker
](
event_based_actor
*
self
)
{
self
->
request
(
worker
,
infinite
,
42
).
then
([](
int
)
{
CAF_FAIL
(
"unexpected handler called"
);
});
});
run_once
();
expect
((
int
),
from
(
client
).
to
(
worker
).
with
(
42
));
expect
((
error
),
from
(
worker
).
to
(
client
).
with
(
sec
::
runtime_error
));
}
#endif // CAF_NO_EXCEPTIONS
CAF_TEST_FIXTURE_SCOPE_END
()
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