tvl-depot/src
Vincent Ambo 0ec214423e 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.
2018-04-12 00:04:37 +02:00
..
db.rs fix(db): Order index threads in descending post time 2018-04-09 23:41:21 +02:00
errors.rs feat(handlers): Use cookie session backend to store author info 2018-04-08 22:56:29 +02:00
handlers.rs fix(handlers): Fix chained error handling in actors 2018-04-12 00:04:37 +02:00
main.rs feat(render): Implement Markdown thread rendering & Gravatar 2018-04-11 13:25:12 +02:00
models.rs feat(handlers): Extract & add author to thread and post information 2018-04-09 09:20:27 +02:00
oidc.rs feat(handlers): Add RequireLogin middleware 2018-04-09 09:11:23 +02:00
render.rs chore: Clean up unused imports 2018-04-11 16:35:26 +02:00
schema.rs chore(models/schema): Update with author fields 2018-04-08 22:37:21 +02:00