Skip to content

Commit

Permalink
don't panic on utf8 error
Browse files Browse the repository at this point in the history
  • Loading branch information
andrieshiemstra committed Oct 15, 2024
1 parent b334c37 commit b0aa0ce
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.14.4

* don't panic on utf8 error in to_str

# 0.14.3

* update quickjs-ng to 0.6.0
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "quickjs_runtime"
version = "0.14.3"
version = "0.14.4"
authors = ["Andries Hiemstra <[email protected]>"]
edition = "2021"
description = "Wrapper API and utils for the QuickJS JavaScript engine with support for Promise, Modules, Async/await"
Expand Down
3 changes: 2 additions & 1 deletion src/quickjs_utils/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ pub unsafe fn to_str(
}

let cstr = std::ffi::CStr::from_ptr(ptr);
Ok(cstr.to_str().expect("bad cstr bad!"))
cstr.to_str()
.map_err(|e| JsError::new_string(format!("utf8 error: {e}")))

//let s = cstr.to_string_lossy();

Expand Down

0 comments on commit b0aa0ce

Please sign in to comment.