pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result<Post, LemmyError> {
blocking(pool, move |conn| Post::read(conn, post_id))
.await?
- .map_err(LemmyError::from)
- .map_err(|e| e.with_message("couldnt_find_post"))
+ .map_err(|e| LemmyError::from_error_message(e, "couldnt_find_post"))
}
#[tracing::instrument(skip_all)]
PostRead::mark_as_read(conn, &post_read_form)
})
.await?
- .map_err(LemmyError::from)
- .map_err(|e| e.with_message("couldnt_mark_post_as_read"))
+ .map_err(|e| LemmyError::from_error_message(e, "couldnt_mark_post_as_read"))
}
#[tracing::instrument(skip_all)]
PostRead::mark_as_unread(conn, &post_read_form)
})
.await?
- .map_err(LemmyError::from)
- .map_err(|e| e.with_message("couldnt_mark_post_as_read"))
+ .map_err(|e| LemmyError::from_error_message(e, "couldnt_mark_post_as_read"))
}
#[tracing::instrument(skip_all)]
secret: &Secret,
) -> Result<LocalUserView, LemmyError> {
let claims = Claims::decode(jwt, &secret.jwt_secret)
- .map_err(LemmyError::from)
.map_err(|e| e.with_message("not_logged_in"))?
.claims;
let local_user_id = LocalUserId(claims.sub);
secret: &Secret,
) -> Result<LocalUserSettingsView, LemmyError> {
let claims = Claims::decode(jwt.as_ref(), &secret.jwt_secret)
- .map_err(LemmyError::from)
.map_err(|e| e.with_message("not_logged_in"))?
.claims;
let local_user_id = LocalUserId(claims.sub);
) -> Result<(), LemmyError> {
let community = blocking(pool, move |conn| Community::read(conn, community_id))
.await?
- .map_err(LemmyError::from)
- .map_err(|e| e.with_message("couldnt_find_community"))?;
+ .map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?;
if community.deleted || community.removed {
Err(LemmyError::from_message("deleted"))
} else {