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:
commit
95358b8864
@ -43,12 +43,12 @@ impl Handler<CreateUser> for DbExecutor {
|
||||
diesel::insert_into(users)
|
||||
.values(&new_user)
|
||||
.execute(conn)
|
||||
.expect("Error inserting person");
|
||||
.map_err(|_| error::ErrorInternalServerError("Error inserting person"))?;
|
||||
|
||||
let mut items = users
|
||||
.filter(id.eq(&uuid))
|
||||
.load::<models::User>(conn)
|
||||
.expect("Error loading person");
|
||||
.map_err(|_| error::ErrorInternalServerError("Error loading person"))?;
|
||||
|
||||
Ok(items.pop().unwrap())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user