refactor(handlers): Improve error handling in post creation

This commit is contained in:
Vincent Ambo 2018-04-14 20:29:46 +02:00 committed by Vincent Ambo
parent 31b0a550f2
commit ea68bac427

View file

@ -165,9 +165,9 @@ pub fn reply_thread(state: State<AppState>,
};
state.db.send(CreatePost(new_post))
.flatten()
.from_err()
.and_then(move |res| {
let post = res?;
.and_then(move |post| {
info!("Posted reply {} to thread {}", post.id, post.thread_id);
Ok(HttpResponse::SeeOther()
.header("Location", format!("/thread/{}#post-{}", post.thread_id, post.id))