Error handling
This commit is contained in:
@ -5,13 +5,13 @@ pub struct Params {
|
||||
user_id: i32,
|
||||
}
|
||||
|
||||
type Response = Result<Json<db::users::UserInfo>, StatusCode>;
|
||||
type Response = GeneralResult<Json<db::users::UserInfo>>;
|
||||
|
||||
pub async fn get(State(pool): State<Pool>, Query(params): Query<Params>) -> Response {
|
||||
let info = db::users::get(params.user_id, &pool)
|
||||
.await
|
||||
.handle_internal()?
|
||||
.ok_or(StatusCode::NOT_FOUND)?;
|
||||
.handle_internal("Error getting the user")?
|
||||
.handle(StatusCode::NOT_FOUND, "User not found")?;
|
||||
Ok(Json(info))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user