diff --git a/cli/main.rs b/cli/main.rs index 1931c62dbe..c73da5e06c 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -1158,13 +1158,7 @@ fn unwrap_or_exit(result: Result) -> T { match result { Ok(value) => value, Err(error) => { - let msg = format!( - "{}: {}", - colors::red_bold("error"), - // TODO(lucacasonato): print anyhow error chain here - error.to_string().trim() - ); - eprintln!("{}", msg); + eprintln!("{}: {:?}", colors::red_bold("error"), error); std::process::exit(1); } } diff --git a/cli/tests/error_027_bare_import_error.ts b/cli/tests/error_027_bare_import_error.ts new file mode 100644 index 0000000000..c0748305d5 --- /dev/null +++ b/cli/tests/error_027_bare_import_error.ts @@ -0,0 +1 @@ +import "foo"; diff --git a/cli/tests/error_027_bare_import_error.ts.out b/cli/tests/error_027_bare_import_error.ts.out new file mode 100644 index 0000000000..b52873d89e --- /dev/null +++ b/cli/tests/error_027_bare_import_error.ts.out @@ -0,0 +1,8 @@ +[WILDCARD]error: Unable to output bundle during Graph::bundle(). + +Caused by: + 0: load_transformed failed + 1: failed to analyze module + 2: failed to resolve foo from + 3: The graph is missing a dependency. + Specifier: foo from file:///[WILDCARD]/error_027_bare_import_error.ts diff --git a/cli/tests/import_data_url_import_relative.ts.out b/cli/tests/import_data_url_import_relative.ts.out index 5123f2fe42..1f4f3e9ef0 100644 --- a/cli/tests/import_data_url_import_relative.ts.out +++ b/cli/tests/import_data_url_import_relative.ts.out @@ -1 +1,4 @@ error: invalid URL: relative URL with a cannot-be-a-base base + +Caused by: + relative URL with a cannot-be-a-base base diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 4be5863513..e7fc7797b1 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -3148,6 +3148,12 @@ console.log("finish"); http_server: true, }); + itest!(error_027_bare_import_error { + args: "bundle error_027_bare_import_error.ts", + output: "error_027_bare_import_error.ts.out", + exit_code: 1, + }); + itest!(error_missing_module_named_import { args: "run --reload error_missing_module_named_import.ts", output: "error_missing_module_named_import.ts.out",