From ff5d072702aee52882787ea85dd73573a8f8f316 Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Tue, 6 Apr 2021 10:33:43 +0200 Subject: refactor: rewrite "net" ops to use serde_v8 (#10028) --- runtime/ops/utils.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 runtime/ops/utils.rs (limited to 'runtime/ops/utils.rs') 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 { + s.into_string().map_err(|s| { + let message = format!("File name or path {:?} is not valid UTF-8", s); + custom_error("InvalidData", message) + }) +} -- cgit v1.2.3