Skip to content

Commit

Permalink
Make felt_from_number report errors properly
Browse files Browse the repository at this point in the history
instead of returning Ok(None) in case of an error
  • Loading branch information
omerfirmak committed Apr 20, 2023
1 parent d545372 commit ee0a5b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/serde/deserialize_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ where
D: Deserializer<'de>,
{
let n = Number::deserialize(deserializer)?;
Ok(Felt252::parse_bytes(n.to_string().as_bytes(), 10))
match Felt252::parse_bytes(n.to_string().as_bytes(), 10) {
Some(x) => Ok(Some(x)),
None => Err(String::from("felt_from_number parse error")).map_err(de::Error::custom),
}
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
Expand Down

0 comments on commit ee0a5b3

Please sign in to comment.