Skip to content

Commit

Permalink
Improve error management
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch committed Dec 13, 2024
1 parent 819670b commit ca38530
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/app/rate_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ pub async fn update_user_reputation_action(
let rating;

if let Some(Payload::RatingUser(v)) = msg.get_inner_message_kind().payload.to_owned() {
if !(MIN_RATING..=MAX_RATING).contains(&v) {
return Err(Error::msg(format!(
"Rating must be between {} and {}",
MIN_RATING, MAX_RATING
)));
}
rating = v;
} else {
return Err(Error::msg("No rating present"));
Expand Down
4 changes: 3 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ pub async fn send_dm(
);

if let Ok(client) = get_nostr_client() {
let _ = client.send_event(event).await;
if let Err(e) = client.send_event(event).await {
error!("Failed to send event: {}", e);
}
}

Ok(())
Expand Down

0 comments on commit ca38530

Please sign in to comment.