diff options
author | Vincent Ambo <tazjin@gmail.com> | 2018-04-11T22·04+0200 |
---|---|---|
committer | Vincent Ambo <tazjin@gmail.com> | 2018-04-11T22·04+0200 |
commit | 0ec214423e0367ad3be21a7c9df5341da3c633c4 (patch) | |
tree | e2a5456d4a44b484429bde640d8e76ba6909e939 /templates | |
parent | a9917d54a82c3ff0dc35b412a85093028d340902 (diff) |
fix(handlers): Fix chained error handling in actors
This took me some time to figure out so it's useful to document in the commit message. When chaining messages from actors, the result type of a message (i.e. the actual `<M as Message>::Result`) is sometimes itself a `Result<T, E>`. In many cases this leads to a situation where the return type of a message sending process is something like (simplified): Future<Item=Result<Foo, ConverseError>, Error=actix::MailboxError> Due to the implementation of `From<actix::MailboxError> for ConverseError` it is possible to use `.from_err()` on these futures to convert the future's `Error` to `ConverseError`. The type `Result` apparently implements `IntoFuture`, which means that due to some trait magic that's been applied somewhere in the futures API a call to `flatten()` can "lift" the contained error if the error types match and give us a "simple" Future<Item=Foo, Error=ConverseError> From that point on chaining becomes easy.
Diffstat (limited to 'templates')
0 files changed, 0 insertions, 0 deletions