Skip to content

Commit

Permalink
handle_session error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderManich committed Nov 29, 2023
1 parent 1943323 commit b2f08ea
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/api/ecdar_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ pub async fn handle_session(
updated_at: Default::default(),
user_id: uid.parse().unwrap(),
})
.await;
return match res {
Ok(_) => Ok(()),
Err(e) => Err(Status::new(Code::Internal, e.to_string())),
};
.await
.map_err(|err| Status::new(Code::Internal, err.to_string()))?;
} else {
let mut session = match session_context
.get_by_token(TokenType::RefreshToken, request.token_string().unwrap())
Expand All @@ -77,10 +74,10 @@ pub async fn handle_session(
session.access_token = access_token.clone();
session.refresh_token = refresh_token.clone();

match session_context.update(session).await {
Ok(_) => (),
Err(err) => return Err(Status::new(Code::Internal, err.to_string())),
};
session_context
.update(session)
.await
.map_err(|err| Status::new(Code::Internal, err.to_string()))?;
}
Ok(())
}
Expand Down

0 comments on commit b2f08ea

Please sign in to comment.