mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 02:22:40 +00:00
refactor: re-export anyhow from deno_core (#12777)
This commit is contained in:
parent
f9f9ddc5e3
commit
b2036a4db7
36 changed files with 165 additions and 179 deletions
|
@ -32,7 +32,7 @@ use deno_ast::Diagnostic;
|
||||||
use deno_ast::LineAndColumnDisplay;
|
use deno_ast::LineAndColumnDisplay;
|
||||||
use deno_ast::MediaType;
|
use deno_ast::MediaType;
|
||||||
use deno_ast::ParsedSource;
|
use deno_ast::ParsedSource;
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
use crate::fs_util::canonicalize_path;
|
use crate::fs_util::canonicalize_path;
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
use deno_core::serde::Deserialize;
|
use deno_core::serde::Deserialize;
|
||||||
use deno_core::serde::Serialize;
|
use deno_core::serde::Serialize;
|
||||||
use deno_core::serde::Serializer;
|
use deno_core::serde::Serializer;
|
||||||
|
|
|
@ -16,9 +16,9 @@ use crate::tsc;
|
||||||
use crate::version;
|
use crate::version;
|
||||||
|
|
||||||
use deno_ast::swc;
|
use deno_ast::swc;
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
use deno_core::serde::Deserialize;
|
use deno_core::serde::Deserialize;
|
||||||
use deno_core::serde::Deserializer;
|
use deno_core::serde::Deserializer;
|
||||||
use deno_core::serde::Serialize;
|
use deno_core::serde::Serialize;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
pub use deno_core::normalize_path;
|
pub use deno_core::normalize_path;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_runtime::deno_crypto::rand;
|
use deno_runtime::deno_crypto::rand;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::tools::lint::create_linter;
|
||||||
use crate::tools::lint::get_configured_rules;
|
use crate::tools::lint::get_configured_rules;
|
||||||
|
|
||||||
use deno_ast::SourceTextInfo;
|
use deno_ast::SourceTextInfo;
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::serde::Deserialize;
|
use deno_core::serde::Deserialize;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use crate::proc_state::ProcState;
|
||||||
use crate::resolver::ImportMapResolver;
|
use crate::resolver::ImportMapResolver;
|
||||||
use crate::resolver::JsxResolver;
|
use crate::resolver::JsxResolver;
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_runtime::permissions::Permissions;
|
use deno_runtime::permissions::Permissions;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::parking_lot::RwLock;
|
use deno_core::parking_lot::RwLock;
|
||||||
use deno_core::serde::Deserialize;
|
use deno_core::serde::Deserialize;
|
||||||
|
|
|
@ -8,7 +8,7 @@ use super::tsc;
|
||||||
|
|
||||||
use crate::diagnostics;
|
use crate::diagnostics;
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::resolve_url;
|
use deno_core::resolve_url;
|
||||||
use deno_core::serde_json::json;
|
use deno_core::serde_json::json;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use deno_ast::MediaType;
|
use deno_ast::MediaType;
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::resolve_url;
|
use deno_core::resolve_url;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use fancy_regex::Regex as FancyRegex;
|
use fancy_regex::Regex as FancyRegex;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
|
@ -15,9 +15,9 @@ use crate::file_fetcher::CacheSetting;
|
||||||
use crate::file_fetcher::FileFetcher;
|
use crate::file_fetcher::FileFetcher;
|
||||||
use crate::http_cache::HttpCache;
|
use crate::http_cache::HttpCache;
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
use deno_core::resolve_url;
|
use deno_core::resolve_url;
|
||||||
use deno_core::serde::Deserialize;
|
use deno_core::serde::Deserialize;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::config_file::TsConfig;
|
||||||
use crate::tsc;
|
use crate::tsc;
|
||||||
use crate::tsc::ResolveArgs;
|
use crate::tsc::ResolveArgs;
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::located_script_name;
|
use deno_core::located_script_name;
|
||||||
|
|
|
@ -9,10 +9,10 @@ use crate::proc_state::ProcState;
|
||||||
use crate::resolver::ImportMapResolver;
|
use crate::resolver::ImportMapResolver;
|
||||||
use crate::resolver::JsxResolver;
|
use crate::resolver::JsxResolver;
|
||||||
|
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
use deno_core::error::generic_error;
|
use deno_core::error::generic_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_core::serde_json::Value;
|
use deno_core::serde_json::Value;
|
||||||
|
|
|
@ -21,10 +21,10 @@ use crate::resolver::JsxResolver;
|
||||||
use crate::source_maps::SourceMapGetter;
|
use crate::source_maps::SourceMapGetter;
|
||||||
use crate::version;
|
use crate::version;
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
use deno_core::parking_lot::Mutex;
|
use deno_core::parking_lot::Mutex;
|
||||||
use deno_core::resolve_url;
|
use deno_core::resolve_url;
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
|
|
|
@ -6,10 +6,10 @@ use crate::flags::Flags;
|
||||||
use crate::ops;
|
use crate::ops;
|
||||||
use crate::proc_state::ProcState;
|
use crate::proc_state::ProcState;
|
||||||
use crate::version;
|
use crate::version;
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::type_error;
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
use deno_core::futures::FutureExt;
|
use deno_core::futures::FutureExt;
|
||||||
use deno_core::located_script_name;
|
use deno_core::located_script_name;
|
||||||
use deno_core::resolve_url;
|
use deno_core::resolve_url;
|
||||||
|
|
|
@ -14,7 +14,10 @@ use crate::fs_util::{collect_files, is_supported_ext};
|
||||||
use crate::tools::fmt::run_parallelized;
|
use crate::tools::fmt::run_parallelized;
|
||||||
use crate::{colors, file_watcher};
|
use crate::{colors, file_watcher};
|
||||||
use deno_ast::MediaType;
|
use deno_ast::MediaType;
|
||||||
use deno_core::error::{anyhow, generic_error, AnyError, JsStackFrame};
|
use deno_core::anyhow::anyhow;
|
||||||
|
use deno_core::error::generic_error;
|
||||||
|
use deno_core::error::AnyError;
|
||||||
|
use deno_core::error::JsStackFrame;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_lint::diagnostic::LintDiagnostic;
|
use deno_lint::diagnostic::LintDiagnostic;
|
||||||
use deno_lint::linter::Linter;
|
use deno_lint::linter::Linter;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::deno_dir::DenoDir;
|
||||||
use crate::flags::DenoSubcommand;
|
use crate::flags::DenoSubcommand;
|
||||||
use crate::flags::Flags;
|
use crate::flags::Flags;
|
||||||
use crate::flags::RunFlags;
|
use crate::flags::RunFlags;
|
||||||
use deno_core::error::bail;
|
use deno_core::anyhow::bail;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::serde_json;
|
use deno_core::serde_json;
|
||||||
use deno_runtime::deno_fetch::reqwest::Client;
|
use deno_runtime::deno_fetch::reqwest::Client;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
//! This module provides feature to upgrade deno executable
|
//! This module provides feature to upgrade deno executable
|
||||||
|
|
||||||
use deno_core::error::bail;
|
use deno_core::anyhow::bail;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::futures::StreamExt;
|
use deno_core::futures::StreamExt;
|
||||||
use deno_runtime::deno_fetch::reqwest;
|
use deno_runtime::deno_fetch::reqwest;
|
||||||
|
|
|
@ -5,9 +5,9 @@ use crate::diagnostics::Diagnostics;
|
||||||
use crate::emit;
|
use crate::emit;
|
||||||
|
|
||||||
use deno_ast::MediaType;
|
use deno_ast::MediaType;
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
use deno_core::located_script_name;
|
use deno_core::located_script_name;
|
||||||
use deno_core::op_sync;
|
use deno_core::op_sync;
|
||||||
use deno_core::resolve_url_or_path;
|
use deno_core::resolve_url_or_path;
|
||||||
|
|
|
@ -537,7 +537,7 @@ mod internal {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::error::AnyError;
|
use anyhow::Error;
|
||||||
use futures::future::pending;
|
use futures::future::pending;
|
||||||
use futures::future::poll_fn;
|
use futures::future::poll_fn;
|
||||||
use futures::future::ready;
|
use futures::future::ready;
|
||||||
|
@ -652,7 +652,7 @@ mod tests {
|
||||||
// Cancel a spawned task before it actually runs.
|
// Cancel a spawned task before it actually runs.
|
||||||
let cancel_handle = Rc::new(CancelHandle::new());
|
let cancel_handle = Rc::new(CancelHandle::new());
|
||||||
let future = spawn(async { panic!("the task should not be spawned") })
|
let future = spawn(async { panic!("the task should not be spawned") })
|
||||||
.map_err(AnyError::from)
|
.map_err(Error::from)
|
||||||
.try_or_cancel(&cancel_handle);
|
.try_or_cancel(&cancel_handle);
|
||||||
cancel_handle.cancel();
|
cancel_handle.cancel();
|
||||||
let error = future.await.unwrap_err();
|
let error = future.await.unwrap_err();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::error::is_instance_of_error;
|
use crate::error::is_instance_of_error;
|
||||||
use crate::error::AnyError;
|
|
||||||
use crate::modules::ModuleMap;
|
use crate::modules::ModuleMap;
|
||||||
use crate::resolve_url_or_path;
|
use crate::resolve_url_or_path;
|
||||||
use crate::JsRuntime;
|
use crate::JsRuntime;
|
||||||
|
@ -12,6 +11,7 @@ use crate::OpResult;
|
||||||
use crate::OpTable;
|
use crate::OpTable;
|
||||||
use crate::PromiseId;
|
use crate::PromiseId;
|
||||||
use crate::ZeroCopyBuf;
|
use crate::ZeroCopyBuf;
|
||||||
|
use anyhow::Error;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
@ -322,7 +322,7 @@ fn opcall_sync<'s>(
|
||||||
|
|
||||||
let op_id = match v8::Local::<v8::Integer>::try_from(args.get(0))
|
let op_id = match v8::Local::<v8::Integer>::try_from(args.get(0))
|
||||||
.map(|l| l.value() as OpId)
|
.map(|l| l.value() as OpId)
|
||||||
.map_err(AnyError::from)
|
.map_err(Error::from)
|
||||||
{
|
{
|
||||||
Ok(op_id) => op_id,
|
Ok(op_id) => op_id,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -379,7 +379,7 @@ fn opcall_async<'s>(
|
||||||
|
|
||||||
let op_id = match v8::Local::<v8::Integer>::try_from(args.get(0))
|
let op_id = match v8::Local::<v8::Integer>::try_from(args.get(0))
|
||||||
.map(|l| l.value() as OpId)
|
.map(|l| l.value() as OpId)
|
||||||
.map_err(AnyError::from)
|
.map_err(Error::from)
|
||||||
{
|
{
|
||||||
Ok(op_id) => op_id,
|
Ok(op_id) => op_id,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -392,7 +392,7 @@ fn opcall_async<'s>(
|
||||||
let arg1 = args.get(1);
|
let arg1 = args.get(1);
|
||||||
let promise_id = v8::Local::<v8::Integer>::try_from(arg1)
|
let promise_id = v8::Local::<v8::Integer>::try_from(arg1)
|
||||||
.map(|l| l.value() as PromiseId)
|
.map(|l| l.value() as PromiseId)
|
||||||
.map_err(AnyError::from);
|
.map_err(Error::from);
|
||||||
// Fail if promise id invalid (not an int)
|
// Fail if promise id invalid (not an int)
|
||||||
let promise_id: PromiseId = match promise_id {
|
let promise_id: PromiseId = match promise_id {
|
||||||
Ok(promise_id) => promise_id,
|
Ok(promise_id) => promise_id,
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
pub use anyhow::anyhow;
|
use anyhow::Error;
|
||||||
pub use anyhow::bail;
|
|
||||||
pub use anyhow::Context;
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::error::Error;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::fmt::Formatter;
|
use std::fmt::Formatter;
|
||||||
|
|
||||||
/// A generic wrapper that can encapsulate any concrete error type.
|
/// A generic wrapper that can encapsulate any concrete error type.
|
||||||
|
// TODO(ry) Deprecate AnyError and encourage deno_core::anyhow::Error instead.
|
||||||
pub type AnyError = anyhow::Error;
|
pub type AnyError = anyhow::Error;
|
||||||
|
|
||||||
/// Creates a new error with a caller-specified error class name and message.
|
/// Creates a new error with a caller-specified error class name and message.
|
||||||
pub fn custom_error(
|
pub fn custom_error(
|
||||||
class: &'static str,
|
class: &'static str,
|
||||||
message: impl Into<Cow<'static, str>>,
|
message: impl Into<Cow<'static, str>>,
|
||||||
) -> AnyError {
|
) -> Error {
|
||||||
CustomError {
|
CustomError {
|
||||||
class,
|
class,
|
||||||
message: message.into(),
|
message: message.into(),
|
||||||
|
@ -25,39 +23,39 @@ pub fn custom_error(
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn generic_error(message: impl Into<Cow<'static, str>>) -> AnyError {
|
pub fn generic_error(message: impl Into<Cow<'static, str>>) -> Error {
|
||||||
custom_error("Error", message)
|
custom_error("Error", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_error(message: impl Into<Cow<'static, str>>) -> AnyError {
|
pub fn type_error(message: impl Into<Cow<'static, str>>) -> Error {
|
||||||
custom_error("TypeError", message)
|
custom_error("TypeError", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn range_error(message: impl Into<Cow<'static, str>>) -> AnyError {
|
pub fn range_error(message: impl Into<Cow<'static, str>>) -> Error {
|
||||||
custom_error("RangeError", message)
|
custom_error("RangeError", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn invalid_hostname(hostname: &str) -> AnyError {
|
pub fn invalid_hostname(hostname: &str) -> Error {
|
||||||
type_error(format!("Invalid hostname: '{}'", hostname))
|
type_error(format!("Invalid hostname: '{}'", hostname))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uri_error(message: impl Into<Cow<'static, str>>) -> AnyError {
|
pub fn uri_error(message: impl Into<Cow<'static, str>>) -> Error {
|
||||||
custom_error("URIError", message)
|
custom_error("URIError", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bad_resource(message: impl Into<Cow<'static, str>>) -> AnyError {
|
pub fn bad_resource(message: impl Into<Cow<'static, str>>) -> Error {
|
||||||
custom_error("BadResource", message)
|
custom_error("BadResource", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bad_resource_id() -> AnyError {
|
pub fn bad_resource_id() -> Error {
|
||||||
custom_error("BadResource", "Bad resource ID")
|
custom_error("BadResource", "Bad resource ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn not_supported() -> AnyError {
|
pub fn not_supported() -> Error {
|
||||||
custom_error("NotSupported", "The operation is not supported")
|
custom_error("NotSupported", "The operation is not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resource_unavailable() -> AnyError {
|
pub fn resource_unavailable() -> Error {
|
||||||
custom_error(
|
custom_error(
|
||||||
"Busy",
|
"Busy",
|
||||||
"Resource is unavailable because it is in use by a promise",
|
"Resource is unavailable because it is in use by a promise",
|
||||||
|
@ -66,7 +64,7 @@ pub fn resource_unavailable() -> AnyError {
|
||||||
|
|
||||||
/// A simple error type that lets the creator specify both the error message and
|
/// A simple error type that lets the creator specify both the error message and
|
||||||
/// the error class name. This type is private; externally it only ever appears
|
/// the error class name. This type is private; externally it only ever appears
|
||||||
/// wrapped in an `AnyError`. To retrieve the error class name from a wrapped
|
/// wrapped in an `anyhow::Error`. To retrieve the error class name from a wrapped
|
||||||
/// `CustomError`, use the function `get_custom_error_class()`.
|
/// `CustomError`, use the function `get_custom_error_class()`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct CustomError {
|
struct CustomError {
|
||||||
|
@ -80,11 +78,11 @@ impl Display for CustomError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for CustomError {}
|
impl std::error::Error for CustomError {}
|
||||||
|
|
||||||
/// If this error was crated with `custom_error()`, return the specified error
|
/// If this error was crated with `custom_error()`, return the specified error
|
||||||
/// class name. In all other cases this function returns `None`.
|
/// class name. In all other cases this function returns `None`.
|
||||||
pub fn get_custom_error_class(error: &AnyError) -> Option<&'static str> {
|
pub fn get_custom_error_class(error: &Error) -> Option<&'static str> {
|
||||||
error.downcast_ref::<CustomError>().map(|e| e.class)
|
error.downcast_ref::<CustomError>().map(|e| e.class)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +166,7 @@ struct NativeJsError {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JsError {
|
impl JsError {
|
||||||
pub(crate) fn create(js_error: Self) -> AnyError {
|
pub(crate) fn create(js_error: Self) -> Error {
|
||||||
js_error.into()
|
js_error.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +243,7 @@ impl JsError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for JsError {}
|
impl std::error::Error for JsError {}
|
||||||
|
|
||||||
fn format_source_loc(
|
fn format_source_loc(
|
||||||
file_name: &str,
|
file_name: &str,
|
||||||
|
@ -283,9 +281,9 @@ impl Display for JsError {
|
||||||
|
|
||||||
pub(crate) fn attach_handle_to_error(
|
pub(crate) fn attach_handle_to_error(
|
||||||
scope: &mut v8::Isolate,
|
scope: &mut v8::Isolate,
|
||||||
err: AnyError,
|
err: Error,
|
||||||
handle: v8::Local<v8::Value>,
|
handle: v8::Local<v8::Value>,
|
||||||
) -> AnyError {
|
) -> Error {
|
||||||
ErrWithV8Handle::new(scope, err, handle).into()
|
ErrWithV8Handle::new(scope, err, handle).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,14 +321,14 @@ pub(crate) fn is_instance_of_error<'s>(
|
||||||
// TODO(piscisaureus): rusty_v8 should implement the Error trait on
|
// TODO(piscisaureus): rusty_v8 should implement the Error trait on
|
||||||
// values of type v8::Global<T>.
|
// values of type v8::Global<T>.
|
||||||
pub(crate) struct ErrWithV8Handle {
|
pub(crate) struct ErrWithV8Handle {
|
||||||
err: AnyError,
|
err: Error,
|
||||||
handle: v8::Global<v8::Value>,
|
handle: v8::Global<v8::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ErrWithV8Handle {
|
impl ErrWithV8Handle {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
scope: &mut v8::Isolate,
|
scope: &mut v8::Isolate,
|
||||||
err: AnyError,
|
err: Error,
|
||||||
handle: v8::Local<v8::Value>,
|
handle: v8::Local<v8::Value>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let handle = v8::Global::new(scope, handle);
|
let handle = v8::Global::new(scope, handle);
|
||||||
|
@ -348,11 +346,11 @@ impl ErrWithV8Handle {
|
||||||
unsafe impl Send for ErrWithV8Handle {}
|
unsafe impl Send for ErrWithV8Handle {}
|
||||||
unsafe impl Sync for ErrWithV8Handle {}
|
unsafe impl Sync for ErrWithV8Handle {}
|
||||||
|
|
||||||
impl Error for ErrWithV8Handle {}
|
impl std::error::Error for ErrWithV8Handle {}
|
||||||
|
|
||||||
impl Display for ErrWithV8Handle {
|
impl Display for ErrWithV8Handle {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
<AnyError as Display>::fmt(&self.err, f)
|
<Error as Display>::fmt(&self.err, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::error::AnyError;
|
use anyhow::Error;
|
||||||
|
|
||||||
pub(crate) fn get_error_code(err: &AnyError) -> Option<&'static str> {
|
pub(crate) fn get_error_code(err: &Error) -> Option<&'static str> {
|
||||||
err
|
err
|
||||||
.downcast_ref::<std::io::Error>()
|
.downcast_ref::<std::io::Error>()
|
||||||
.map(|e| match e.raw_os_error() {
|
.map(|e| match e.raw_os_error() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
use deno_core::error::AnyError;
|
use deno_core::anyhow::Error;
|
||||||
use deno_core::AsyncRefCell;
|
use deno_core::AsyncRefCell;
|
||||||
use deno_core::AsyncResult;
|
use deno_core::AsyncResult;
|
||||||
use deno_core::CancelHandle;
|
use deno_core::CancelHandle;
|
||||||
|
@ -12,7 +12,6 @@ use deno_core::ResourceId;
|
||||||
use deno_core::ZeroCopyBuf;
|
use deno_core::ZeroCopyBuf;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::io::Error;
|
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
|
@ -43,7 +42,7 @@ struct TcpListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TcpListener {
|
impl TcpListener {
|
||||||
async fn accept(self: Rc<Self>) -> Result<TcpStream, Error> {
|
async fn accept(self: Rc<Self>) -> Result<TcpStream, std::io::Error> {
|
||||||
let cancel = RcRef::map(&self, |r| &r.cancel);
|
let cancel = RcRef::map(&self, |r| &r.cancel);
|
||||||
let stream = self.inner.accept().try_or_cancel(cancel).await?.0.into();
|
let stream = self.inner.accept().try_or_cancel(cancel).await?.0.into();
|
||||||
Ok(stream)
|
Ok(stream)
|
||||||
|
@ -57,7 +56,7 @@ impl Resource for TcpListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<std::net::TcpListener> for TcpListener {
|
impl TryFrom<std::net::TcpListener> for TcpListener {
|
||||||
type Error = Error;
|
type Error = std::io::Error;
|
||||||
fn try_from(
|
fn try_from(
|
||||||
std_listener: std::net::TcpListener,
|
std_listener: std::net::TcpListener,
|
||||||
) -> Result<Self, Self::Error> {
|
) -> Result<Self, Self::Error> {
|
||||||
|
@ -78,21 +77,18 @@ struct TcpStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TcpStream {
|
impl TcpStream {
|
||||||
async fn read(
|
async fn read(self: Rc<Self>, mut buf: ZeroCopyBuf) -> Result<usize, Error> {
|
||||||
self: Rc<Self>,
|
|
||||||
mut buf: ZeroCopyBuf,
|
|
||||||
) -> Result<usize, AnyError> {
|
|
||||||
let mut rd = RcRef::map(&self, |r| &r.rd).borrow_mut().await;
|
let mut rd = RcRef::map(&self, |r| &r.rd).borrow_mut().await;
|
||||||
let cancel = RcRef::map(self, |r| &r.cancel);
|
let cancel = RcRef::map(self, |r| &r.cancel);
|
||||||
rd.read(&mut buf)
|
rd.read(&mut buf)
|
||||||
.try_or_cancel(cancel)
|
.try_or_cancel(cancel)
|
||||||
.await
|
.await
|
||||||
.map_err(AnyError::from)
|
.map_err(Error::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn write(self: Rc<Self>, buf: ZeroCopyBuf) -> Result<usize, AnyError> {
|
async fn write(self: Rc<Self>, buf: ZeroCopyBuf) -> Result<usize, Error> {
|
||||||
let mut wr = RcRef::map(self, |r| &r.wr).borrow_mut().await;
|
let mut wr = RcRef::map(self, |r| &r.wr).borrow_mut().await;
|
||||||
wr.write(&buf).await.map_err(AnyError::from)
|
wr.write(&buf).await.map_err(Error::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,11 +125,7 @@ fn create_js_runtime() -> JsRuntime {
|
||||||
runtime
|
runtime
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_listen(
|
fn op_listen(state: &mut OpState, _: (), _: ()) -> Result<ResourceId, Error> {
|
||||||
state: &mut OpState,
|
|
||||||
_: (),
|
|
||||||
_: (),
|
|
||||||
) -> Result<ResourceId, AnyError> {
|
|
||||||
log::debug!("listen");
|
log::debug!("listen");
|
||||||
let addr = "127.0.0.1:4544".parse::<SocketAddr>().unwrap();
|
let addr = "127.0.0.1:4544".parse::<SocketAddr>().unwrap();
|
||||||
let std_listener = std::net::TcpListener::bind(&addr)?;
|
let std_listener = std::net::TcpListener::bind(&addr)?;
|
||||||
|
@ -147,7 +139,7 @@ async fn op_accept(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, Error> {
|
||||||
log::debug!("accept rid={}", rid);
|
log::debug!("accept rid={}", rid);
|
||||||
|
|
||||||
let listener = state.borrow().resource_table.get::<TcpListener>(rid)?;
|
let listener = state.borrow().resource_table.get::<TcpListener>(rid)?;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use crate::error::AnyError;
|
use crate::OpFn;
|
||||||
use crate::{OpFn, OpState};
|
use crate::OpState;
|
||||||
|
use anyhow::Error;
|
||||||
|
|
||||||
pub type SourcePair = (&'static str, Box<SourceLoadFn>);
|
pub type SourcePair = (&'static str, Box<SourceLoadFn>);
|
||||||
pub type SourceLoadFn = dyn Fn() -> Result<String, AnyError>;
|
pub type SourceLoadFn = dyn Fn() -> Result<String, Error>;
|
||||||
pub type OpPair = (&'static str, Box<OpFn>);
|
pub type OpPair = (&'static str, Box<OpFn>);
|
||||||
pub type OpMiddlewareFn = dyn Fn(&'static str, Box<OpFn>) -> Box<OpFn>;
|
pub type OpMiddlewareFn = dyn Fn(&'static str, Box<OpFn>) -> Box<OpFn>;
|
||||||
pub type OpStateFn = dyn Fn(&mut OpState) -> Result<(), AnyError>;
|
pub type OpStateFn = dyn Fn(&mut OpState) -> Result<(), Error>;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Extension {
|
pub struct Extension {
|
||||||
|
@ -44,7 +45,7 @@ impl Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allows setting up the initial op-state of an isolate at startup.
|
/// Allows setting up the initial op-state of an isolate at startup.
|
||||||
pub fn init_state(&self, state: &mut OpState) -> Result<(), AnyError> {
|
pub fn init_state(&self, state: &mut OpState) -> Result<(), Error> {
|
||||||
match &self.opstate_fn {
|
match &self.opstate_fn {
|
||||||
Some(ofn) => ofn(state),
|
Some(ofn) => ofn(state),
|
||||||
None => Ok(()),
|
None => Ok(()),
|
||||||
|
@ -79,7 +80,7 @@ impl ExtensionBuilder {
|
||||||
|
|
||||||
pub fn state<F>(&mut self, opstate_fn: F) -> &mut Self
|
pub fn state<F>(&mut self, opstate_fn: F) -> &mut Self
|
||||||
where
|
where
|
||||||
F: Fn(&mut OpState) -> Result<(), AnyError> + 'static,
|
F: Fn(&mut OpState) -> Result<(), Error> + 'static,
|
||||||
{
|
{
|
||||||
self.state = Some(Box::new(opstate_fn));
|
self.state = Some(Box::new(opstate_fn));
|
||||||
self
|
self
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
//! <https://hyperandroid.com/2020/02/12/v8-inspector-from-an-embedder-standpoint/>
|
//! <https://hyperandroid.com/2020/02/12/v8-inspector-from-an-embedder-standpoint/>
|
||||||
|
|
||||||
use crate::error::generic_error;
|
use crate::error::generic_error;
|
||||||
use crate::error::AnyError;
|
|
||||||
use crate::futures::channel::mpsc;
|
use crate::futures::channel::mpsc;
|
||||||
use crate::futures::channel::mpsc::UnboundedReceiver;
|
use crate::futures::channel::mpsc::UnboundedReceiver;
|
||||||
use crate::futures::channel::mpsc::UnboundedSender;
|
use crate::futures::channel::mpsc::UnboundedSender;
|
||||||
|
@ -22,6 +21,7 @@ use crate::futures::task::Poll;
|
||||||
use crate::serde_json;
|
use crate::serde_json;
|
||||||
use crate::serde_json::json;
|
use crate::serde_json::json;
|
||||||
use crate::serde_json::Value;
|
use crate::serde_json::Value;
|
||||||
|
use anyhow::Error;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::cell::BorrowMutError;
|
use std::cell::BorrowMutError;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -637,7 +637,7 @@ impl LocalInspectorSession {
|
||||||
&mut self,
|
&mut self,
|
||||||
method: &str,
|
method: &str,
|
||||||
params: Option<serde_json::Value>,
|
params: Option<serde_json::Value>,
|
||||||
) -> Result<serde_json::Value, AnyError> {
|
) -> Result<serde_json::Value, Error> {
|
||||||
let id = self.next_message_id;
|
let id = self.next_message_id;
|
||||||
self.next_message_id += 1;
|
self.next_message_id += 1;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ mod resources;
|
||||||
mod runtime;
|
mod runtime;
|
||||||
|
|
||||||
// Re-exports
|
// Re-exports
|
||||||
|
pub use anyhow;
|
||||||
pub use futures;
|
pub use futures;
|
||||||
pub use parking_lot;
|
pub use parking_lot;
|
||||||
pub use serde;
|
pub use serde;
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
use crate::bindings;
|
use crate::bindings;
|
||||||
use crate::error::generic_error;
|
use crate::error::generic_error;
|
||||||
use crate::error::AnyError;
|
|
||||||
use crate::module_specifier::ModuleSpecifier;
|
use crate::module_specifier::ModuleSpecifier;
|
||||||
use crate::runtime::exception_to_err_result;
|
use crate::runtime::exception_to_err_result;
|
||||||
use crate::OpState;
|
use crate::OpState;
|
||||||
|
use anyhow::Error;
|
||||||
use futures::future::FutureExt;
|
use futures::future::FutureExt;
|
||||||
use futures::stream::FuturesUnordered;
|
use futures::stream::FuturesUnordered;
|
||||||
use futures::stream::Stream;
|
use futures::stream::Stream;
|
||||||
|
@ -54,9 +54,8 @@ pub struct ModuleSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PrepareLoadFuture =
|
pub type PrepareLoadFuture =
|
||||||
dyn Future<Output = (ModuleLoadId, Result<RecursiveModuleLoad, AnyError>)>;
|
dyn Future<Output = (ModuleLoadId, Result<RecursiveModuleLoad, Error>)>;
|
||||||
pub type ModuleSourceFuture =
|
pub type ModuleSourceFuture = dyn Future<Output = Result<ModuleSource, Error>>;
|
||||||
dyn Future<Output = Result<ModuleSource, AnyError>>;
|
|
||||||
|
|
||||||
pub trait ModuleLoader {
|
pub trait ModuleLoader {
|
||||||
/// Returns an absolute URL.
|
/// Returns an absolute URL.
|
||||||
|
@ -71,7 +70,7 @@ pub trait ModuleLoader {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError>;
|
) -> Result<ModuleSpecifier, Error>;
|
||||||
|
|
||||||
/// Given ModuleSpecifier, load its source code.
|
/// Given ModuleSpecifier, load its source code.
|
||||||
///
|
///
|
||||||
|
@ -99,7 +98,7 @@ pub trait ModuleLoader {
|
||||||
_module_specifier: &ModuleSpecifier,
|
_module_specifier: &ModuleSpecifier,
|
||||||
_maybe_referrer: Option<String>,
|
_maybe_referrer: Option<String>,
|
||||||
_is_dyn_import: bool,
|
_is_dyn_import: bool,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<(), AnyError>>>> {
|
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
|
||||||
async { Ok(()) }.boxed_local()
|
async { Ok(()) }.boxed_local()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +113,7 @@ impl ModuleLoader for NoopModuleLoader {
|
||||||
_specifier: &str,
|
_specifier: &str,
|
||||||
_referrer: &str,
|
_referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
Err(generic_error("Module loading is not supported"))
|
Err(generic_error("Module loading is not supported"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ impl ModuleLoader for FsModuleLoader {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
Ok(crate::resolve_import(specifier, referrer)?)
|
Ok(crate::resolve_import(specifier, referrer)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +256,7 @@ impl RecursiveModuleLoad {
|
||||||
load
|
load
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_root(&self) -> Result<ModuleSpecifier, AnyError> {
|
pub fn resolve_root(&self) -> Result<ModuleSpecifier, Error> {
|
||||||
match self.init {
|
match self.init {
|
||||||
LoadInit::Main(ref specifier) => {
|
LoadInit::Main(ref specifier) => {
|
||||||
self.loader.resolve(specifier, ".", true)
|
self.loader.resolve(specifier, ".", true)
|
||||||
|
@ -271,7 +270,7 @@ impl RecursiveModuleLoad {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn prepare(&self) -> Result<(), AnyError> {
|
pub async fn prepare(&self) -> Result<(), Error> {
|
||||||
let op_state = self.op_state.clone();
|
let op_state = self.op_state.clone();
|
||||||
let (module_specifier, maybe_referrer) = match self.init {
|
let (module_specifier, maybe_referrer) = match self.init {
|
||||||
LoadInit::Main(ref specifier) => {
|
LoadInit::Main(ref specifier) => {
|
||||||
|
@ -310,7 +309,7 @@ impl RecursiveModuleLoad {
|
||||||
&mut self,
|
&mut self,
|
||||||
scope: &mut v8::HandleScope,
|
scope: &mut v8::HandleScope,
|
||||||
module_source: &ModuleSource,
|
module_source: &ModuleSource,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
// Register the module in the module map unless it's already there. If the
|
// Register the module in the module map unless it's already there. If the
|
||||||
// specified URL and the "true" URL are different, register the alias.
|
// specified URL and the "true" URL are different, register the alias.
|
||||||
if module_source.module_url_specified != module_source.module_url_found {
|
if module_source.module_url_specified != module_source.module_url_found {
|
||||||
|
@ -392,7 +391,7 @@ impl RecursiveModuleLoad {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stream for RecursiveModuleLoad {
|
impl Stream for RecursiveModuleLoad {
|
||||||
type Item = Result<ModuleSource, AnyError>;
|
type Item = Result<ModuleSource, Error>;
|
||||||
|
|
||||||
fn poll_next(
|
fn poll_next(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
|
@ -529,7 +528,7 @@ impl ModuleMap {
|
||||||
main: bool,
|
main: bool,
|
||||||
name: &str,
|
name: &str,
|
||||||
source: &str,
|
source: &str,
|
||||||
) -> Result<ModuleId, AnyError> {
|
) -> Result<ModuleId, Error> {
|
||||||
let name_str = v8::String::new(scope, name).unwrap();
|
let name_str = v8::String::new(scope, name).unwrap();
|
||||||
let source_str = v8::String::new(scope, source).unwrap();
|
let source_str = v8::String::new(scope, source).unwrap();
|
||||||
|
|
||||||
|
@ -637,7 +636,7 @@ impl ModuleMap {
|
||||||
pub async fn load_main(
|
pub async fn load_main(
|
||||||
module_map_rc: Rc<RefCell<ModuleMap>>,
|
module_map_rc: Rc<RefCell<ModuleMap>>,
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
) -> Result<RecursiveModuleLoad, AnyError> {
|
) -> Result<RecursiveModuleLoad, Error> {
|
||||||
let load = RecursiveModuleLoad::main(specifier, module_map_rc.clone());
|
let load = RecursiveModuleLoad::main(specifier, module_map_rc.clone());
|
||||||
load.prepare().await?;
|
load.prepare().await?;
|
||||||
Ok(load)
|
Ok(load)
|
||||||
|
@ -646,7 +645,7 @@ impl ModuleMap {
|
||||||
pub async fn load_side(
|
pub async fn load_side(
|
||||||
module_map_rc: Rc<RefCell<ModuleMap>>,
|
module_map_rc: Rc<RefCell<ModuleMap>>,
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
) -> Result<RecursiveModuleLoad, AnyError> {
|
) -> Result<RecursiveModuleLoad, Error> {
|
||||||
let load = RecursiveModuleLoad::side(specifier, module_map_rc.clone());
|
let load = RecursiveModuleLoad::side(specifier, module_map_rc.clone());
|
||||||
load.prepare().await?;
|
load.prepare().await?;
|
||||||
Ok(load)
|
Ok(load)
|
||||||
|
@ -727,7 +726,6 @@ mod tests {
|
||||||
use crate::RuntimeOptions;
|
use crate::RuntimeOptions;
|
||||||
use futures::future::FutureExt;
|
use futures::future::FutureExt;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::error::Error;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -791,8 +789,8 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for MockError {
|
impl std::error::Error for MockError {
|
||||||
fn cause(&self) -> Option<&dyn Error> {
|
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -803,7 +801,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Future for DelayedSourceCodeFuture {
|
impl Future for DelayedSourceCodeFuture {
|
||||||
type Output = Result<ModuleSource, AnyError>;
|
type Output = Result<ModuleSource, Error>;
|
||||||
|
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> {
|
||||||
let inner = self.get_mut();
|
let inner = self.get_mut();
|
||||||
|
@ -834,7 +832,7 @@ mod tests {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_root: bool,
|
_is_root: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
let referrer = if referrer == "." {
|
let referrer = if referrer == "." {
|
||||||
"file:///"
|
"file:///"
|
||||||
} else {
|
} else {
|
||||||
|
@ -978,7 +976,7 @@ mod tests {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
self.count.fetch_add(1, Ordering::Relaxed);
|
self.count.fetch_add(1, Ordering::Relaxed);
|
||||||
assert_eq!(specifier, "./b.js");
|
assert_eq!(specifier, "./b.js");
|
||||||
assert_eq!(referrer, "file:///a.js");
|
assert_eq!(referrer, "file:///a.js");
|
||||||
|
@ -1096,7 +1094,7 @@ mod tests {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
self.count.fetch_add(1, Ordering::Relaxed);
|
self.count.fetch_add(1, Ordering::Relaxed);
|
||||||
assert_eq!(specifier, "/foo.js");
|
assert_eq!(specifier, "/foo.js");
|
||||||
assert_eq!(referrer, "file:///dyn_import2.js");
|
assert_eq!(referrer, "file:///dyn_import2.js");
|
||||||
|
@ -1156,7 +1154,7 @@ mod tests {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
let c = self.resolve_count.fetch_add(1, Ordering::Relaxed);
|
let c = self.resolve_count.fetch_add(1, Ordering::Relaxed);
|
||||||
assert!(c < 7);
|
assert!(c < 7);
|
||||||
assert_eq!(specifier, "./b.js");
|
assert_eq!(specifier, "./b.js");
|
||||||
|
@ -1187,7 +1185,7 @@ mod tests {
|
||||||
_module_specifier: &ModuleSpecifier,
|
_module_specifier: &ModuleSpecifier,
|
||||||
_maybe_referrer: Option<String>,
|
_maybe_referrer: Option<String>,
|
||||||
_is_dyn_import: bool,
|
_is_dyn_import: bool,
|
||||||
) -> Pin<Box<dyn Future<Output = Result<(), AnyError>>>> {
|
) -> Pin<Box<dyn Future<Output = Result<(), Error>>>> {
|
||||||
self.prepare_load_count.fetch_add(1, Ordering::Relaxed);
|
self.prepare_load_count.fetch_add(1, Ordering::Relaxed);
|
||||||
async { Ok(()) }.boxed_local()
|
async { Ok(()) }.boxed_local()
|
||||||
}
|
}
|
||||||
|
@ -1292,7 +1290,7 @@ mod tests {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
self.resolve_count.fetch_add(1, Ordering::Relaxed);
|
self.resolve_count.fetch_add(1, Ordering::Relaxed);
|
||||||
let s = crate::resolve_import(specifier, referrer).unwrap();
|
let s = crate::resolve_import(specifier, referrer).unwrap();
|
||||||
Ok(s)
|
Ok(s)
|
||||||
|
@ -1634,7 +1632,7 @@ mod tests {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
let s = crate::resolve_import(specifier, referrer).unwrap();
|
let s = crate::resolve_import(specifier, referrer).unwrap();
|
||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
|
|
10
core/ops.rs
10
core/ops.rs
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::error::type_error;
|
use crate::error::type_error;
|
||||||
use crate::error::AnyError;
|
|
||||||
use crate::gotham_state::GothamState;
|
use crate::gotham_state::GothamState;
|
||||||
use crate::ops_metrics::OpsTracker;
|
use crate::ops_metrics::OpsTracker;
|
||||||
use crate::resources::ResourceTable;
|
use crate::resources::ResourceTable;
|
||||||
use crate::runtime::GetErrorClassFn;
|
use crate::runtime::GetErrorClassFn;
|
||||||
|
use anyhow::Error;
|
||||||
use futures::future::maybe_done;
|
use futures::future::maybe_done;
|
||||||
use futures::future::FusedFuture;
|
use futures::future::FusedFuture;
|
||||||
use futures::future::MaybeDone;
|
use futures::future::MaybeDone;
|
||||||
|
@ -96,13 +96,13 @@ pub struct OpPayload<'a, 'b, 'c> {
|
||||||
impl<'a, 'b, 'c> OpPayload<'a, 'b, 'c> {
|
impl<'a, 'b, 'c> OpPayload<'a, 'b, 'c> {
|
||||||
pub fn deserialize<T: DeserializeOwned, U: DeserializeOwned>(
|
pub fn deserialize<T: DeserializeOwned, U: DeserializeOwned>(
|
||||||
self,
|
self,
|
||||||
) -> Result<(T, U), AnyError> {
|
) -> Result<(T, U), Error> {
|
||||||
let a: T = serde_v8::from_v8(self.scope, self.a)
|
let a: T = serde_v8::from_v8(self.scope, self.a)
|
||||||
.map_err(AnyError::from)
|
.map_err(Error::from)
|
||||||
.map_err(|e| type_error(format!("Error parsing args: {}", e)))?;
|
.map_err(|e| type_error(format!("Error parsing args: {}", e)))?;
|
||||||
|
|
||||||
let b: U = serde_v8::from_v8(self.scope, self.b)
|
let b: U = serde_v8::from_v8(self.scope, self.b)
|
||||||
.map_err(AnyError::from)
|
.map_err(Error::from)
|
||||||
.map_err(|e| type_error(format!("Error parsing args: {}", e)))?;
|
.map_err(|e| type_error(format!("Error parsing args: {}", e)))?;
|
||||||
Ok((a, b))
|
Ok((a, b))
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ pub struct OpError {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn serialize_op_result<R: Serialize + 'static>(
|
pub fn serialize_op_result<R: Serialize + 'static>(
|
||||||
result: Result<R, AnyError>,
|
result: Result<R, Error>,
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
) -> OpResult {
|
) -> OpResult {
|
||||||
match result {
|
match result {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::error::type_error;
|
use crate::error::type_error;
|
||||||
use crate::error::AnyError;
|
|
||||||
use crate::include_js_files;
|
use crate::include_js_files;
|
||||||
use crate::op_async;
|
use crate::op_async;
|
||||||
use crate::op_sync;
|
use crate::op_sync;
|
||||||
|
@ -11,6 +10,7 @@ use crate::Extension;
|
||||||
use crate::OpState;
|
use crate::OpState;
|
||||||
use crate::Resource;
|
use crate::Resource;
|
||||||
use crate::ZeroCopyBuf;
|
use crate::ZeroCopyBuf;
|
||||||
|
use anyhow::Error;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::io::{stderr, stdout, Write};
|
use std::io::{stderr, stdout, Write};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -51,7 +51,7 @@ pub fn op_resources(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_: (),
|
_: (),
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<Vec<(ResourceId, String)>, AnyError> {
|
) -> Result<Vec<(ResourceId, String)>, Error> {
|
||||||
let serialized_resources = state
|
let serialized_resources = state
|
||||||
.resource_table
|
.resource_table
|
||||||
.names()
|
.names()
|
||||||
|
@ -65,7 +65,7 @@ pub fn op_close(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: Option<ResourceId>,
|
rid: Option<ResourceId>,
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
// TODO(@AaronO): drop Option after improving type-strictness balance in
|
// TODO(@AaronO): drop Option after improving type-strictness balance in
|
||||||
// serde_v8
|
// serde_v8
|
||||||
let rid = rid.ok_or_else(|| type_error("missing or invalid `rid`"))?;
|
let rid = rid.ok_or_else(|| type_error("missing or invalid `rid`"))?;
|
||||||
|
@ -79,7 +79,7 @@ pub fn op_try_close(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: Option<ResourceId>,
|
rid: Option<ResourceId>,
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
// TODO(@AaronO): drop Option after improving type-strictness balance in
|
// TODO(@AaronO): drop Option after improving type-strictness balance in
|
||||||
// serde_v8.
|
// serde_v8.
|
||||||
let rid = rid.ok_or_else(|| type_error("missing or invalid `rid`"))?;
|
let rid = rid.ok_or_else(|| type_error("missing or invalid `rid`"))?;
|
||||||
|
@ -92,7 +92,7 @@ pub fn op_print(
|
||||||
_state: &mut OpState,
|
_state: &mut OpState,
|
||||||
msg: String,
|
msg: String,
|
||||||
is_err: bool,
|
is_err: bool,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
if is_err {
|
if is_err {
|
||||||
stderr().write_all(msg.as_bytes())?;
|
stderr().write_all(msg.as_bytes())?;
|
||||||
stderr().flush().unwrap();
|
stderr().flush().unwrap();
|
||||||
|
@ -123,7 +123,7 @@ pub fn op_wasm_streaming_feed(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
bytes: ZeroCopyBuf,
|
bytes: ZeroCopyBuf,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
let wasm_streaming =
|
let wasm_streaming =
|
||||||
state.resource_table.get::<WasmStreamingResource>(rid)?;
|
state.resource_table.get::<WasmStreamingResource>(rid)?;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ pub fn op_wasm_streaming_abort(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
exception: serde_v8::Value,
|
exception: serde_v8::Value,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
let wasm_streaming =
|
let wasm_streaming =
|
||||||
state.resource_table.take::<WasmStreamingResource>(rid)?;
|
state.resource_table.take::<WasmStreamingResource>(rid)?;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ pub fn op_wasm_streaming_set_url(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
url: String,
|
url: String,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
let wasm_streaming =
|
let wasm_streaming =
|
||||||
state.resource_table.get::<WasmStreamingResource>(rid)?;
|
state.resource_table.get::<WasmStreamingResource>(rid)?;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ pub fn op_metrics(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
_: (),
|
_: (),
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<(OpMetrics, Vec<OpMetrics>), AnyError> {
|
) -> Result<(OpMetrics, Vec<OpMetrics>), Error> {
|
||||||
let aggregate = state.tracker.aggregate();
|
let aggregate = state.tracker.aggregate();
|
||||||
let per_op = state.tracker.per_op();
|
let per_op = state.tracker.per_op();
|
||||||
Ok((aggregate, per_op))
|
Ok((aggregate, per_op))
|
||||||
|
@ -180,7 +180,7 @@ async fn op_read(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
buf: ZeroCopyBuf,
|
buf: ZeroCopyBuf,
|
||||||
) -> Result<u32, AnyError> {
|
) -> Result<u32, Error> {
|
||||||
let resource = state.borrow().resource_table.get_any(rid)?;
|
let resource = state.borrow().resource_table.get_any(rid)?;
|
||||||
resource.read(buf).await.map(|n| n as u32)
|
resource.read(buf).await.map(|n| n as u32)
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ async fn op_write(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
buf: ZeroCopyBuf,
|
buf: ZeroCopyBuf,
|
||||||
) -> Result<u32, AnyError> {
|
) -> Result<u32, Error> {
|
||||||
let resource = state.borrow().resource_table.get_any(rid)?;
|
let resource = state.borrow().resource_table.get_any(rid)?;
|
||||||
resource.write(buf).await.map(|n| n as u32)
|
resource.write(buf).await.map(|n| n as u32)
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ async fn op_shutdown(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
let resource = state.borrow().resource_table.get_any(rid)?;
|
let resource = state.borrow().resource_table.get_any(rid)?;
|
||||||
resource.shutdown().await
|
resource.shutdown().await
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::error::AnyError;
|
|
||||||
use crate::ops::OpCall;
|
use crate::ops::OpCall;
|
||||||
use crate::serialize_op_result;
|
use crate::serialize_op_result;
|
||||||
use crate::Op;
|
use crate::Op;
|
||||||
use crate::OpFn;
|
use crate::OpFn;
|
||||||
use crate::OpState;
|
use crate::OpState;
|
||||||
|
use anyhow::Error;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
|
@ -51,7 +51,7 @@ pub fn void_op_async() -> Box<OpFn> {
|
||||||
/// A more complete example is available in the examples directory.
|
/// A more complete example is available in the examples directory.
|
||||||
pub fn op_sync<F, A, B, R>(op_fn: F) -> Box<OpFn>
|
pub fn op_sync<F, A, B, R>(op_fn: F) -> Box<OpFn>
|
||||||
where
|
where
|
||||||
F: Fn(&mut OpState, A, B) -> Result<R, AnyError> + 'static,
|
F: Fn(&mut OpState, A, B) -> Result<R, Error> + 'static,
|
||||||
A: DeserializeOwned,
|
A: DeserializeOwned,
|
||||||
B: DeserializeOwned,
|
B: DeserializeOwned,
|
||||||
R: Serialize + 'static,
|
R: Serialize + 'static,
|
||||||
|
@ -96,7 +96,7 @@ where
|
||||||
F: Fn(Rc<RefCell<OpState>>, A, B) -> R + 'static,
|
F: Fn(Rc<RefCell<OpState>>, A, B) -> R + 'static,
|
||||||
A: DeserializeOwned,
|
A: DeserializeOwned,
|
||||||
B: DeserializeOwned,
|
B: DeserializeOwned,
|
||||||
R: Future<Output = Result<RV, AnyError>> + 'static,
|
R: Future<Output = Result<RV, Error>> + 'static,
|
||||||
RV: Serialize + 'static,
|
RV: Serialize + 'static,
|
||||||
{
|
{
|
||||||
Box::new(move |state, payload| -> Op {
|
Box::new(move |state, payload| -> Op {
|
||||||
|
@ -106,7 +106,7 @@ where
|
||||||
let args = match payload.deserialize() {
|
let args = match payload.deserialize() {
|
||||||
Ok(args) => args,
|
Ok(args) => args,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Op::Sync(serialize_op_result(Err::<(), AnyError>(err), state))
|
return Op::Sync(serialize_op_result(Err::<(), Error>(err), state))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let (a, b) = args;
|
let (a, b) = args;
|
||||||
|
@ -128,7 +128,7 @@ where
|
||||||
F: Fn(Rc<RefCell<OpState>>, A, B) -> R + 'static,
|
F: Fn(Rc<RefCell<OpState>>, A, B) -> R + 'static,
|
||||||
A: DeserializeOwned,
|
A: DeserializeOwned,
|
||||||
B: DeserializeOwned,
|
B: DeserializeOwned,
|
||||||
R: Future<Output = Result<RV, AnyError>> + 'static,
|
R: Future<Output = Result<RV, Error>> + 'static,
|
||||||
RV: Serialize + 'static,
|
RV: Serialize + 'static,
|
||||||
{
|
{
|
||||||
Box::new(move |state, payload| -> Op {
|
Box::new(move |state, payload| -> Op {
|
||||||
|
@ -138,7 +138,7 @@ where
|
||||||
let args = match payload.deserialize() {
|
let args = match payload.deserialize() {
|
||||||
Ok(args) => args,
|
Ok(args) => args,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Op::Sync(serialize_op_result(Err::<(), AnyError>(err), state))
|
return Op::Sync(serialize_op_result(Err::<(), Error>(err), state))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let (a, b) = args;
|
let (a, b) = args;
|
||||||
|
@ -162,7 +162,7 @@ mod tests {
|
||||||
_state: Rc<RefCell<OpState>>,
|
_state: Rc<RefCell<OpState>>,
|
||||||
msg: Option<String>,
|
msg: Option<String>,
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
assert_eq!(msg.unwrap(), "hello");
|
assert_eq!(msg.unwrap(), "hello");
|
||||||
Err(crate::error::generic_error("foo"))
|
Err(crate::error::generic_error("foo"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
use crate::error::bad_resource_id;
|
use crate::error::bad_resource_id;
|
||||||
use crate::error::not_supported;
|
use crate::error::not_supported;
|
||||||
use crate::error::AnyError;
|
|
||||||
use crate::ZeroCopyBuf;
|
use crate::ZeroCopyBuf;
|
||||||
|
use anyhow::Error;
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use std::any::type_name;
|
use std::any::type_name;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
@ -21,7 +21,7 @@ use std::pin::Pin;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
/// Returned by resource read/write/shutdown methods
|
/// Returned by resource read/write/shutdown methods
|
||||||
pub type AsyncResult<T> = Pin<Box<dyn Future<Output = Result<T, AnyError>>>>;
|
pub type AsyncResult<T> = Pin<Box<dyn Future<Output = Result<T, Error>>>>;
|
||||||
|
|
||||||
/// All objects that can be store in the resource table should implement the
|
/// All objects that can be store in the resource table should implement the
|
||||||
/// `Resource` trait.
|
/// `Resource` trait.
|
||||||
|
@ -130,7 +130,7 @@ impl ResourceTable {
|
||||||
/// Returns a reference counted pointer to the resource of type `T` with the
|
/// Returns a reference counted pointer to the resource of type `T` with the
|
||||||
/// given `rid`. If `rid` is not present or has a type different than `T`,
|
/// given `rid`. If `rid` is not present or has a type different than `T`,
|
||||||
/// this function returns `None`.
|
/// this function returns `None`.
|
||||||
pub fn get<T: Resource>(&self, rid: ResourceId) -> Result<Rc<T>, AnyError> {
|
pub fn get<T: Resource>(&self, rid: ResourceId) -> Result<Rc<T>, Error> {
|
||||||
self
|
self
|
||||||
.index
|
.index
|
||||||
.get(&rid)
|
.get(&rid)
|
||||||
|
@ -139,7 +139,7 @@ impl ResourceTable {
|
||||||
.ok_or_else(bad_resource_id)
|
.ok_or_else(bad_resource_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_any(&self, rid: ResourceId) -> Result<Rc<dyn Resource>, AnyError> {
|
pub fn get_any(&self, rid: ResourceId) -> Result<Rc<dyn Resource>, Error> {
|
||||||
self
|
self
|
||||||
.index
|
.index
|
||||||
.get(&rid)
|
.get(&rid)
|
||||||
|
@ -151,10 +151,7 @@ impl ResourceTable {
|
||||||
/// If a resource with the given `rid` exists but its type does not match `T`,
|
/// If a resource with the given `rid` exists but its type does not match `T`,
|
||||||
/// it is not removed from the resource table. Note that the resource's
|
/// it is not removed from the resource table. Note that the resource's
|
||||||
/// `close()` method is *not* called.
|
/// `close()` method is *not* called.
|
||||||
pub fn take<T: Resource>(
|
pub fn take<T: Resource>(&mut self, rid: ResourceId) -> Result<Rc<T>, Error> {
|
||||||
&mut self,
|
|
||||||
rid: ResourceId,
|
|
||||||
) -> Result<Rc<T>, AnyError> {
|
|
||||||
let resource = self.get::<T>(rid)?;
|
let resource = self.get::<T>(rid)?;
|
||||||
self.index.remove(&rid);
|
self.index.remove(&rid);
|
||||||
Ok(resource)
|
Ok(resource)
|
||||||
|
@ -165,7 +162,7 @@ impl ResourceTable {
|
||||||
pub fn take_any(
|
pub fn take_any(
|
||||||
&mut self,
|
&mut self,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
) -> Result<Rc<dyn Resource>, AnyError> {
|
) -> Result<Rc<dyn Resource>, Error> {
|
||||||
self.index.remove(&rid).ok_or_else(bad_resource_id)
|
self.index.remove(&rid).ok_or_else(bad_resource_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +172,7 @@ impl ResourceTable {
|
||||||
/// counted, therefore pending ops are not automatically cancelled. A resource
|
/// counted, therefore pending ops are not automatically cancelled. A resource
|
||||||
/// may implement the `close()` method to perform clean-ups such as canceling
|
/// may implement the `close()` method to perform clean-ups such as canceling
|
||||||
/// ops.
|
/// ops.
|
||||||
pub fn close(&mut self, rid: ResourceId) -> Result<(), AnyError> {
|
pub fn close(&mut self, rid: ResourceId) -> Result<(), Error> {
|
||||||
self
|
self
|
||||||
.index
|
.index
|
||||||
.remove(&rid)
|
.remove(&rid)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
use crate::bindings;
|
use crate::bindings;
|
||||||
use crate::error::attach_handle_to_error;
|
use crate::error::attach_handle_to_error;
|
||||||
use crate::error::generic_error;
|
use crate::error::generic_error;
|
||||||
use crate::error::AnyError;
|
|
||||||
use crate::error::ErrWithV8Handle;
|
use crate::error::ErrWithV8Handle;
|
||||||
use crate::error::JsError;
|
use crate::error::JsError;
|
||||||
use crate::inspector::JsRuntimeInspector;
|
use crate::inspector::JsRuntimeInspector;
|
||||||
|
@ -20,6 +19,7 @@ use crate::OpPayload;
|
||||||
use crate::OpResult;
|
use crate::OpResult;
|
||||||
use crate::OpState;
|
use crate::OpState;
|
||||||
use crate::PromiseId;
|
use crate::PromiseId;
|
||||||
|
use anyhow::Error;
|
||||||
use futures::channel::oneshot;
|
use futures::channel::oneshot;
|
||||||
use futures::future::poll_fn;
|
use futures::future::poll_fn;
|
||||||
use futures::future::FutureExt;
|
use futures::future::FutureExt;
|
||||||
|
@ -47,10 +47,9 @@ pub enum Snapshot {
|
||||||
Boxed(Box<[u8]>),
|
Boxed(Box<[u8]>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type JsErrorCreateFn = dyn Fn(JsError) -> AnyError;
|
pub type JsErrorCreateFn = dyn Fn(JsError) -> Error;
|
||||||
|
|
||||||
pub type GetErrorClassFn =
|
pub type GetErrorClassFn = &'static dyn for<'e> Fn(&'e Error) -> &'static str;
|
||||||
&'static dyn for<'e> Fn(&'e AnyError) -> &'static str;
|
|
||||||
|
|
||||||
/// Objects that need to live as long as the isolate
|
/// Objects that need to live as long as the isolate
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -91,7 +90,7 @@ struct DynImportModEvaluate {
|
||||||
|
|
||||||
struct ModEvaluate {
|
struct ModEvaluate {
|
||||||
promise: v8::Global<v8::Promise>,
|
promise: v8::Global<v8::Promise>,
|
||||||
sender: oneshot::Sender<Result<(), AnyError>>,
|
sender: oneshot::Sender<Result<(), Error>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CrossIsolateStore<T>(Arc<Mutex<CrossIsolateStoreInner<T>>>);
|
pub struct CrossIsolateStore<T>(Arc<Mutex<CrossIsolateStoreInner<T>>>);
|
||||||
|
@ -450,7 +449,7 @@ impl JsRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes JS of provided Extensions
|
/// Initializes JS of provided Extensions
|
||||||
fn init_extension_js(&mut self) -> Result<(), AnyError> {
|
fn init_extension_js(&mut self) -> Result<(), Error> {
|
||||||
// Take extensions to avoid double-borrow
|
// Take extensions to avoid double-borrow
|
||||||
let mut extensions: Vec<Extension> = std::mem::take(&mut self.extensions);
|
let mut extensions: Vec<Extension> = std::mem::take(&mut self.extensions);
|
||||||
for m in extensions.iter_mut() {
|
for m in extensions.iter_mut() {
|
||||||
|
@ -468,7 +467,7 @@ impl JsRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes ops of provided Extensions
|
/// Initializes ops of provided Extensions
|
||||||
fn init_extension_ops(&mut self) -> Result<(), AnyError> {
|
fn init_extension_ops(&mut self) -> Result<(), Error> {
|
||||||
let op_state = self.op_state();
|
let op_state = self.op_state();
|
||||||
// Take extensions to avoid double-borrow
|
// Take extensions to avoid double-borrow
|
||||||
let mut extensions: Vec<Extension> = std::mem::take(&mut self.extensions);
|
let mut extensions: Vec<Extension> = std::mem::take(&mut self.extensions);
|
||||||
|
@ -552,14 +551,14 @@ impl JsRuntime {
|
||||||
///
|
///
|
||||||
/// The same `name` value can be used for multiple executions.
|
/// The same `name` value can be used for multiple executions.
|
||||||
///
|
///
|
||||||
/// `AnyError` can be downcast to a type that exposes additional information
|
/// `Error` can be downcast to a type that exposes additional information
|
||||||
/// about the V8 exception. By default this type is `JsError`, however it may
|
/// about the V8 exception. By default this type is `JsError`, however it may
|
||||||
/// be a different type if `RuntimeOptions::js_error_create_fn` has been set.
|
/// be a different type if `RuntimeOptions::js_error_create_fn` has been set.
|
||||||
pub fn execute_script(
|
pub fn execute_script(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &str,
|
name: &str,
|
||||||
source_code: &str,
|
source_code: &str,
|
||||||
) -> Result<v8::Global<v8::Value>, AnyError> {
|
) -> Result<v8::Global<v8::Value>, Error> {
|
||||||
let scope = &mut self.handle_scope();
|
let scope = &mut self.handle_scope();
|
||||||
|
|
||||||
let source = v8::String::new(scope, source_code).unwrap();
|
let source = v8::String::new(scope, source_code).unwrap();
|
||||||
|
@ -592,7 +591,7 @@ impl JsRuntime {
|
||||||
/// Takes a snapshot. The isolate should have been created with will_snapshot
|
/// Takes a snapshot. The isolate should have been created with will_snapshot
|
||||||
/// set to true.
|
/// set to true.
|
||||||
///
|
///
|
||||||
/// `AnyError` can be downcast to a type that exposes additional information
|
/// `Error` can be downcast to a type that exposes additional information
|
||||||
/// about the V8 exception. By default this type is `JsError`, however it may
|
/// about the V8 exception. By default this type is `JsError`, however it may
|
||||||
/// be a different type if `RuntimeOptions::js_error_create_fn` has been set.
|
/// be a different type if `RuntimeOptions::js_error_create_fn` has been set.
|
||||||
pub fn snapshot(&mut self) -> v8::StartupData {
|
pub fn snapshot(&mut self) -> v8::StartupData {
|
||||||
|
@ -702,7 +701,7 @@ impl JsRuntime {
|
||||||
pub async fn resolve_value(
|
pub async fn resolve_value(
|
||||||
&mut self,
|
&mut self,
|
||||||
global: v8::Global<v8::Value>,
|
global: v8::Global<v8::Value>,
|
||||||
) -> Result<v8::Global<v8::Value>, AnyError> {
|
) -> Result<v8::Global<v8::Value>, Error> {
|
||||||
poll_fn(|cx| {
|
poll_fn(|cx| {
|
||||||
let state = self.poll_event_loop(cx, false);
|
let state = self.poll_event_loop(cx, false);
|
||||||
|
|
||||||
|
@ -746,7 +745,7 @@ impl JsRuntime {
|
||||||
pub async fn run_event_loop(
|
pub async fn run_event_loop(
|
||||||
&mut self,
|
&mut self,
|
||||||
wait_for_inspector: bool,
|
wait_for_inspector: bool,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
poll_fn(|cx| self.poll_event_loop(cx, wait_for_inspector)).await
|
poll_fn(|cx| self.poll_event_loop(cx, wait_for_inspector)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,7 +757,7 @@ impl JsRuntime {
|
||||||
&mut self,
|
&mut self,
|
||||||
cx: &mut Context,
|
cx: &mut Context,
|
||||||
wait_for_inspector: bool,
|
wait_for_inspector: bool,
|
||||||
) -> Poll<Result<(), AnyError>> {
|
) -> Poll<Result<(), Error>> {
|
||||||
// We always poll the inspector first
|
// We always poll the inspector first
|
||||||
let _ = self.inspector().poll_unpin(cx);
|
let _ = self.inspector().poll_unpin(cx);
|
||||||
|
|
||||||
|
@ -902,7 +901,7 @@ pub(crate) fn exception_to_err_result<'s, T>(
|
||||||
scope: &mut v8::HandleScope<'s>,
|
scope: &mut v8::HandleScope<'s>,
|
||||||
exception: v8::Local<v8::Value>,
|
exception: v8::Local<v8::Value>,
|
||||||
in_promise: bool,
|
in_promise: bool,
|
||||||
) -> Result<T, AnyError> {
|
) -> Result<T, Error> {
|
||||||
let is_terminating_exception = scope.is_execution_terminating();
|
let is_terminating_exception = scope.is_execution_terminating();
|
||||||
let mut exception = exception;
|
let mut exception = exception;
|
||||||
|
|
||||||
|
@ -943,7 +942,7 @@ impl JsRuntime {
|
||||||
pub(crate) fn instantiate_module(
|
pub(crate) fn instantiate_module(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: ModuleId,
|
id: ModuleId,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
let module_map_rc = Self::module_map(self.v8_isolate());
|
let module_map_rc = Self::module_map(self.v8_isolate());
|
||||||
let scope = &mut self.handle_scope();
|
let scope = &mut self.handle_scope();
|
||||||
let tc_scope = &mut v8::TryCatch::new(scope);
|
let tc_scope = &mut v8::TryCatch::new(scope);
|
||||||
|
@ -981,7 +980,7 @@ impl JsRuntime {
|
||||||
&mut self,
|
&mut self,
|
||||||
load_id: ModuleLoadId,
|
load_id: ModuleLoadId,
|
||||||
id: ModuleId,
|
id: ModuleId,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
let state_rc = Self::state(self.v8_isolate());
|
let state_rc = Self::state(self.v8_isolate());
|
||||||
let module_map_rc = Self::module_map(self.v8_isolate());
|
let module_map_rc = Self::module_map(self.v8_isolate());
|
||||||
|
|
||||||
|
@ -1058,7 +1057,7 @@ impl JsRuntime {
|
||||||
/// Implementors must manually call `run_event_loop()` to drive module
|
/// Implementors must manually call `run_event_loop()` to drive module
|
||||||
/// evaluation future.
|
/// evaluation future.
|
||||||
///
|
///
|
||||||
/// `AnyError` can be downcast to a type that exposes additional information
|
/// `Error` can be downcast to a type that exposes additional information
|
||||||
/// about the V8 exception. By default this type is `JsError`, however it may
|
/// about the V8 exception. By default this type is `JsError`, however it may
|
||||||
/// be a different type if `RuntimeOptions::js_error_create_fn` has been set.
|
/// be a different type if `RuntimeOptions::js_error_create_fn` has been set.
|
||||||
///
|
///
|
||||||
|
@ -1066,7 +1065,7 @@ impl JsRuntime {
|
||||||
pub fn mod_evaluate(
|
pub fn mod_evaluate(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: ModuleId,
|
id: ModuleId,
|
||||||
) -> oneshot::Receiver<Result<(), AnyError>> {
|
) -> oneshot::Receiver<Result<(), Error>> {
|
||||||
let state_rc = Self::state(self.v8_isolate());
|
let state_rc = Self::state(self.v8_isolate());
|
||||||
let module_map_rc = Self::module_map(self.v8_isolate());
|
let module_map_rc = Self::module_map(self.v8_isolate());
|
||||||
let scope = &mut self.handle_scope();
|
let scope = &mut self.handle_scope();
|
||||||
|
@ -1130,7 +1129,7 @@ impl JsRuntime {
|
||||||
receiver
|
receiver
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dynamic_import_reject(&mut self, id: ModuleLoadId, err: AnyError) {
|
fn dynamic_import_reject(&mut self, id: ModuleLoadId, err: Error) {
|
||||||
let module_map_rc = Self::module_map(self.v8_isolate());
|
let module_map_rc = Self::module_map(self.v8_isolate());
|
||||||
let scope = &mut self.handle_scope();
|
let scope = &mut self.handle_scope();
|
||||||
|
|
||||||
|
@ -1193,7 +1192,7 @@ impl JsRuntime {
|
||||||
fn prepare_dyn_imports(
|
fn prepare_dyn_imports(
|
||||||
&mut self,
|
&mut self,
|
||||||
cx: &mut Context,
|
cx: &mut Context,
|
||||||
) -> Poll<Result<(), AnyError>> {
|
) -> Poll<Result<(), Error>> {
|
||||||
let module_map_rc = Self::module_map(self.v8_isolate());
|
let module_map_rc = Self::module_map(self.v8_isolate());
|
||||||
|
|
||||||
if module_map_rc.borrow().preparing_dynamic_imports.is_empty() {
|
if module_map_rc.borrow().preparing_dynamic_imports.is_empty() {
|
||||||
|
@ -1230,10 +1229,7 @@ impl JsRuntime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_dyn_imports(
|
fn poll_dyn_imports(&mut self, cx: &mut Context) -> Poll<Result<(), Error>> {
|
||||||
&mut self,
|
|
||||||
cx: &mut Context,
|
|
||||||
) -> Poll<Result<(), AnyError>> {
|
|
||||||
let module_map_rc = Self::module_map(self.v8_isolate());
|
let module_map_rc = Self::module_map(self.v8_isolate());
|
||||||
|
|
||||||
if module_map_rc.borrow().pending_dynamic_imports.is_empty() {
|
if module_map_rc.borrow().pending_dynamic_imports.is_empty() {
|
||||||
|
@ -1408,7 +1404,7 @@ impl JsRuntime {
|
||||||
&mut self,
|
&mut self,
|
||||||
specifier: &ModuleSpecifier,
|
specifier: &ModuleSpecifier,
|
||||||
code: Option<String>,
|
code: Option<String>,
|
||||||
) -> Result<ModuleId, AnyError> {
|
) -> Result<ModuleId, Error> {
|
||||||
let module_map_rc = Self::module_map(self.v8_isolate());
|
let module_map_rc = Self::module_map(self.v8_isolate());
|
||||||
if let Some(code) = code {
|
if let Some(code) = code {
|
||||||
module_map_rc.borrow_mut().new_module(
|
module_map_rc.borrow_mut().new_module(
|
||||||
|
@ -1445,7 +1441,7 @@ impl JsRuntime {
|
||||||
&mut self,
|
&mut self,
|
||||||
specifier: &ModuleSpecifier,
|
specifier: &ModuleSpecifier,
|
||||||
code: Option<String>,
|
code: Option<String>,
|
||||||
) -> Result<ModuleId, AnyError> {
|
) -> Result<ModuleId, Error> {
|
||||||
let module_map_rc = Self::module_map(self.v8_isolate());
|
let module_map_rc = Self::module_map(self.v8_isolate());
|
||||||
if let Some(code) = code {
|
if let Some(code) = code {
|
||||||
module_map_rc.borrow_mut().new_module(
|
module_map_rc.borrow_mut().new_module(
|
||||||
|
@ -1471,7 +1467,7 @@ impl JsRuntime {
|
||||||
Ok(root_id)
|
Ok(root_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_promise_exceptions(&mut self) -> Result<(), AnyError> {
|
fn check_promise_exceptions(&mut self) -> Result<(), Error> {
|
||||||
let state_rc = Self::state(self.v8_isolate());
|
let state_rc = Self::state(self.v8_isolate());
|
||||||
let mut state = state_rc.borrow_mut();
|
let mut state = state_rc.borrow_mut();
|
||||||
|
|
||||||
|
@ -1496,7 +1492,7 @@ impl JsRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send finished responses to JS
|
// Send finished responses to JS
|
||||||
fn resolve_async_ops(&mut self, cx: &mut Context) -> Result<(), AnyError> {
|
fn resolve_async_ops(&mut self, cx: &mut Context) -> Result<(), Error> {
|
||||||
let state_rc = Self::state(self.v8_isolate());
|
let state_rc = Self::state(self.v8_isolate());
|
||||||
|
|
||||||
let js_recv_cb_handle = state_rc.borrow().js_recv_cb.clone().unwrap();
|
let js_recv_cb_handle = state_rc.borrow().js_recv_cb.clone().unwrap();
|
||||||
|
@ -1552,7 +1548,7 @@ impl JsRuntime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn drain_macrotasks(&mut self) -> Result<(), AnyError> {
|
fn drain_macrotasks(&mut self) -> Result<(), Error> {
|
||||||
let js_macrotask_cb_handle =
|
let js_macrotask_cb_handle =
|
||||||
match &Self::state(self.v8_isolate()).borrow().js_macrotask_cb {
|
match &Self::state(self.v8_isolate()).borrow().js_macrotask_cb {
|
||||||
Some(handle) => handle.clone(),
|
Some(handle) => handle.clone(),
|
||||||
|
@ -1909,11 +1905,11 @@ pub mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_error_builder() {
|
fn test_error_builder() {
|
||||||
fn op_err(_: &mut OpState, _: (), _: ()) -> Result<(), AnyError> {
|
fn op_err(_: &mut OpState, _: (), _: ()) -> Result<(), Error> {
|
||||||
Err(custom_error("DOMExceptionOperationError", "abc"))
|
Err(custom_error("DOMExceptionOperationError", "abc"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_error_class_name(_: &AnyError) -> &'static str {
|
pub fn get_error_class_name(_: &Error) -> &'static str {
|
||||||
"DOMExceptionOperationError"
|
"DOMExceptionOperationError"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2077,7 +2073,7 @@ pub mod tests {
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
referrer: &str,
|
referrer: &str,
|
||||||
_is_main: bool,
|
_is_main: bool,
|
||||||
) -> Result<ModuleSpecifier, AnyError> {
|
) -> Result<ModuleSpecifier, Error> {
|
||||||
assert_eq!(specifier, "file:///main.js");
|
assert_eq!(specifier, "file:///main.js");
|
||||||
assert_eq!(referrer, ".");
|
assert_eq!(referrer, ".");
|
||||||
let s = crate::resolve_import(specifier, referrer).unwrap();
|
let s = crate::resolve_import(specifier, referrer).unwrap();
|
||||||
|
@ -2316,7 +2312,7 @@ assertEquals(1, notify_return_value);
|
||||||
op_state: Rc<RefCell<OpState>>,
|
op_state: Rc<RefCell<OpState>>,
|
||||||
_: (),
|
_: (),
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), Error> {
|
||||||
let n = {
|
let n = {
|
||||||
let op_state = op_state.borrow();
|
let op_state = op_state.borrow();
|
||||||
let inner_state = op_state.borrow::<InnerState>();
|
let inner_state = op_state.borrow::<InnerState>();
|
||||||
|
|
|
@ -6,7 +6,7 @@ pub use rustls_native_certs;
|
||||||
pub use webpki;
|
pub use webpki;
|
||||||
pub use webpki_roots;
|
pub use webpki_roots;
|
||||||
|
|
||||||
use deno_core::error::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::error::custom_error;
|
use deno_core::error::custom_error;
|
||||||
use deno_core::error::generic_error;
|
use deno_core::error::generic_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
pub use deno_core::normalize_path;
|
pub use deno_core::normalize_path;
|
||||||
use std::env::current_dir;
|
use std::env::current_dir;
|
||||||
use std::io::Error;
|
use std::io::Error;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::permissions::Permissions;
|
use crate::permissions::Permissions;
|
||||||
|
use deno_core::anyhow::Context;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::Context;
|
|
||||||
use deno_core::op_sync;
|
use deno_core::op_sync;
|
||||||
use deno_core::Extension;
|
use deno_core::Extension;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue