1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-22 15:06:54 -05:00
denoland-deno/runtime/ops/utils.rs
Bartek Iwańczuk 4894e500cf
refactor: move TaskQueue from deno_runtime to deno_core (#18016)
This utility is useful in several contexts so it seems reasonable to
have it in `deno_core`.
2023-03-05 00:10:31 +00:00

12 lines
421 B
Rust

// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
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 {s:?} is not valid UTF-8");
custom_error("InvalidData", message)
})
}