summaryrefslogtreecommitdiff
path: root/cli/ops/runtime_compiler.rs
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2021-01-29 10:33:58 +0900
committerGitHub <noreply@github.com>2021-01-29 10:33:58 +0900
commitfc162162a155faf088f2b1a3343597c66d59d98c (patch)
treebe6831e9c52152753147fb4376815ab42325720f /cli/ops/runtime_compiler.rs
parent6ecc86cf2ae4bb0aac6f3d0e954382a69176b387 (diff)
fix(cli): fix panic in Deno.emit (#9302)
Diffstat (limited to 'cli/ops/runtime_compiler.rs')
-rw-r--r--cli/ops/runtime_compiler.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/cli/ops/runtime_compiler.rs b/cli/ops/runtime_compiler.rs
index 481b29a11..60aa07bdd 100644
--- a/cli/ops/runtime_compiler.rs
+++ b/cli/ops/runtime_compiler.rs
@@ -10,6 +10,7 @@ use crate::specifier_handler::MemoryHandler;
use crate::specifier_handler::SpecifierHandler;
use deno_core::error::generic_error;
+use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::error::Context;
use deno_core::serde_json;
@@ -55,6 +56,7 @@ async fn op_emit(
) -> Result<Value, AnyError> {
deno_runtime::ops::check_unstable2(&state, "Deno.emit");
let args: EmitArgs = serde_json::from_value(args)?;
+ let root_specifier = args.root_specifier;
let program_state = state.borrow().borrow::<Arc<ProgramState>>().clone();
let runtime_permissions = {
let state = state.borrow();
@@ -92,9 +94,16 @@ async fn op_emit(
None
};
let mut builder = GraphBuilder::new(handler, maybe_import_map, None);
- let root_specifier =
- ModuleSpecifier::resolve_url_or_path(&args.root_specifier)?;
- builder.add(&root_specifier, is_dynamic).await?;
+ let root_specifier = ModuleSpecifier::resolve_url_or_path(&root_specifier)?;
+ builder
+ .add(&root_specifier, is_dynamic)
+ .await
+ .map_err(|_| {
+ type_error(format!(
+ "Unable to handle the given specifier: {}",
+ &root_specifier
+ ))
+ })?;
let bundle_type = match args.bundle {
Some(RuntimeBundleType::Esm) => BundleType::Esm,
_ => BundleType::None,