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:
parent
02b8850cdf
commit
84c1087de0
@ -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())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user