Skip to content

Commit

Permalink
Refactor error handling in compileSierraToCasm function
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkushinDaniil committed Aug 12, 2024
1 parent 982b903 commit 5113fca
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ use std::{
#[no_mangle]
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn Cairo0ClassHash(class_json_str: *const c_char, hash: *mut c_uchar) {
let class_json = unsafe { CStr::from_ptr(class_json_str) }.to_str().unwrap();
let class_json = unsafe { CStr::from_ptr(class_json_str) };
let class_json = match class_json.to_str() {
Ok(s) => s,
Err(_) => return,
};
let class: Result<LegacyContractClass, serde_json::Error> = serde_json::from_str(class_json);

let class = match class {
Expand Down

0 comments on commit 5113fca

Please sign in to comment.