From 88e6e9c1e6263f326d30b7fcc33465e0428faf33 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Wed, 14 Jun 2023 10:45:59 -0600 Subject: refactor(core): some runtime methods should live on the module map (#19502) A few easy migrations of module code from the runtime to the module map. The module map already has a few places where it needs a handle scope, so we're not coupling it any further with the v8 runtime. `init_runtime_module_map` is replaced with an option to reduce API surface of JsRuntime. `module_resolve_callback` now lives in the `ModuleMap` and we use a annex data to avoid having to go through the `Rc>` stored in the `JsRuntime`'s isolate. --- core/error.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core/error.rs') diff --git a/core/error.rs b/core/error.rs index 07dc98a22..55fdcaa7c 100644 --- a/core/error.rs +++ b/core/error.rs @@ -695,6 +695,12 @@ pub(crate) fn exception_to_err_result( Err(js_error.into()) } +pub fn throw_type_error(scope: &mut v8::HandleScope, message: impl AsRef) { + let message = v8::String::new(scope, message.as_ref()).unwrap(); + let exception = v8::Exception::type_error(scope, message); + scope.throw_exception(exception); +} + #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3