diff options
Diffstat (limited to 'runtime/ops/utils.rs')
-rw-r--r-- | runtime/ops/utils.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/ops/utils.rs b/runtime/ops/utils.rs new file mode 100644 index 000000000..881522b07 --- /dev/null +++ b/runtime/ops/utils.rs @@ -0,0 +1,10 @@ +use deno_core::error::custom_error; +use deno_core::error::AnyError; + +/// A utility function to map OsStrings to Strings +pub fn into_string(s: std::ffi::OsString) -> Result<String, AnyError> { + s.into_string().map_err(|s| { + let message = format!("File name or path {:?} is not valid UTF-8", s); + custom_error("InvalidData", message) + }) +} |