Skip to content

Commit

Permalink
Use continue instead return for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ninokeldishvili committed Oct 18, 2024
1 parent 7cf9bcb commit 16634bb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/author/authors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ pub async fn get_authors(manager: &str, url: &str) -> Result<Vec<String>> {
if let Some(meta_value) = item["meta"].as_str() {
if meta_value.len() < 18 {
// Avoid any out-of-bounds access
return Err(anyhow::anyhow!("Invalid meta data: too short"));
tracing::error!("Invalid meta data: too short");
continue;
}

let extracted_substring = &meta_value[18..]; // Remove rain meta magic_number
Expand All @@ -80,7 +81,8 @@ pub async fn get_authors(manager: &str, url: &str) -> Result<Vec<String>> {
let bytes_array_meta = match hex::decode(extracted_substring) {
Ok(bytes) => bytes,
Err(e) => {
return Err(anyhow::anyhow!("Failed to decode hex string: {:?}", e));
tracing::error!("Failed to decode hex string: {:?}", e);
continue;
}
};

Expand All @@ -90,8 +92,9 @@ pub async fn get_authors(manager: &str, url: &str) -> Result<Vec<String>> {
let payload = &cbor_decoded[0].payload;

// Ensure that the payload is of the correct length
if payload.is_empty() || payload[0] != 1 {
return Err(anyhow::anyhow!("Invalid payload structure"));
if payload.is_empty() {
tracing::error!("Invalid payload structure: {:?}", item);
continue;
}

let address_str: String = hex::encode(payload);
Expand All @@ -101,7 +104,8 @@ pub async fn get_authors(manager: &str, url: &str) -> Result<Vec<String>> {
if modified_address.len() == 42 {
addresses.push(modified_address);
} else {
return Err(anyhow::anyhow!("Invalid address format"));
tracing::error!("Invalid Address format");
continue;
}
}
Err(err) => {
Expand Down

0 comments on commit 16634bb

Please sign in to comment.