diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-06 10:33:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 10:33:43 +0200 |
commit | ff5d072702aee52882787ea85dd73573a8f8f316 (patch) | |
tree | 346d9ac446bbb307edaac0ce965b36dfe511305e /runtime/ops/utils.rs | |
parent | 2c52c0a145337050fee03313a7c5698b761969dc (diff) |
refactor: rewrite "net" ops to use serde_v8 (#10028)
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) + }) +} |