1
0
mirror of https://github.com/actix/examples synced 2024-11-23 22:41:07 +01:00

Don't panic on DB error

This commit is contained in:
Pirmin Kalberer 2018-04-28 00:05:14 +02:00
parent 02b8850cdf
commit 84c1087de0

View File

@ -43,12 +43,12 @@ impl Handler<CreateUser> for DbExecutor {
diesel::insert_into(users) diesel::insert_into(users)
.values(&new_user) .values(&new_user)
.execute(conn) .execute(conn)
.expect("Error inserting person"); .map_err(|_| error::ErrorInternalServerError("Error inserting person"))?;
let mut items = users let mut items = users
.filter(id.eq(&uuid)) .filter(id.eq(&uuid))
.load::<models::User>(conn) .load::<models::User>(conn)
.expect("Error loading person"); .map_err(|_| error::ErrorInternalServerError("Error loading person"))?;
Ok(items.pop().unwrap()) Ok(items.pop().unwrap())
} }