mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 07:19:03 +08:00
fix(rust): avoid panic always
This commit is contained in:
parent
ce2c51f6c1
commit
e8a6c1bb65
@ -317,7 +317,12 @@ fn _transform_html_inner(opts: TranformHTMLOptions) -> Result<String, ()> {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn transform_html(opts: *const libc::c_char) -> *mut i8 {
|
||||
let opts: TranformHTMLOptions = serde_json::de::from_str(&unsafe { CStr::from_ptr(opts) }.to_str().unwrap()).unwrap();
|
||||
let opts: TranformHTMLOptions = match unsafe { CStr::from_ptr(opts) }.to_str().map_err(|_| ()).and_then(|x| serde_json::de::from_str(&x).map_err(|_| ())) {
|
||||
Ok(x) => x,
|
||||
Err(_) => {
|
||||
return CString::new("RUSTFC:ERROR").unwrap().into_raw();
|
||||
}
|
||||
};
|
||||
|
||||
let out = match _transform_html_inner(opts) {
|
||||
Ok(x) => x,
|
||||
|
Loading…
x
Reference in New Issue
Block a user