Skip to content

Commit d59ae9e

Browse files
committed
controllers/session: Simplify save_user_to_database() return type
1 parent 3dff767 commit d59ae9e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/controllers/session.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async fn save_user_to_database(
139139
access_token: &str,
140140
emails: &Emails,
141141
conn: &mut AsyncPgConnection,
142-
) -> AppResult<User> {
142+
) -> QueryResult<User> {
143143
let new_user = NewUser::builder()
144144
.gh_id(user.id)
145145
.gh_login(&user.login)
@@ -156,11 +156,9 @@ async fn save_user_to_database(
156156
Err(error) if is_read_only_error(&error) => {
157157
// If we're in read only mode, we can't update their details
158158
// just look for an existing user
159-
find_user_by_gh_id(conn, user.id)
160-
.await?
161-
.ok_or_else(|| error.into())
159+
find_user_by_gh_id(conn, user.id).await?.ok_or(error)
162160
}
163-
Err(error) => Err(error.into()),
161+
Err(error) => Err(error),
164162
}
165163
}
166164

0 commit comments

Comments
 (0)