summaryrefslogtreecommitdiff
path: root/runtime/ops/utils.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-04-06 10:33:43 +0200
committerGitHub <noreply@github.com>2021-04-06 10:33:43 +0200
commitff5d072702aee52882787ea85dd73573a8f8f316 (patch)
tree346d9ac446bbb307edaac0ce965b36dfe511305e /runtime/ops/utils.rs
parent2c52c0a145337050fee03313a7c5698b761969dc (diff)
refactor: rewrite "net" ops to use serde_v8 (#10028)
Diffstat (limited to 'runtime/ops/utils.rs')
-rw-r--r--runtime/ops/utils.rs10
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)
+ })
+}