Benjamin Bannier created MESOS-8925:
---------------------------------------
Summary: Support flattening from Try with custom errors into Future
Key: MESOS-8925
URL: https://issues.apache.org/jira/browse/MESOS-8925
Project: Mesos
Issue Type: Improvement
Components: libprocess
Reporter: Benjamin Bannier
{{Try<T, E>}} is parameterized on the type of the error and defaults to the
pretty {{std::string}}-like {{Error}}. Custom error types allow propagating
domain specific failure information and can e.g., be used to implement more
granular error handling.
While we currently support flattening a {{Try<T, Error>}} into a {{Future}},
this is e.g., not possible for error types not derived from {{Error}}. This
lack of genericness hampers effective use of composition of functions producing
a {{Try}} with non-{{Error}} failures with asynchronous computations.
>From the implementation side this lack of support seems to mostly hinge on
>{{Failure}} being non-generic and very {{Error}}-like (which in turn is very
>{{std::string}}-like).
We should consider either
# making {{Failure}} a template accepting generic error types ({{Future}}
would be parameterized on the same error type as well then), or
# supporting construction of {{Failure}} from generic error types, but only
requiring that the type can be stringified.
While the former approach would add the same extensibility {{Try}} already
provides to {{Future}}, the latter would at least allow non-{{Error}} {{Try}}
values to propagate into {{Future}} values.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)