1
0
mirror of https://github.com/actix/examples synced 2025-01-22 14:05:55 +01:00

Merge pull request #8 from pka/handle-diesel-error

Don't panic on DB error
This commit is contained in:
Nikolay Kim 2018-04-27 15:19:07 -07:00 committed by GitHub
commit 95358b8864
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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())
} }