mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor: move JsError formatting to deno_runtime (#15345)
This takes the existing `fmt_error` module from cli and puts it as a public module into `deno_runtime`.
This commit is contained in:
parent
4f8dea100e
commit
63b8089bda
8 changed files with 9 additions and 8 deletions
|
@ -1,12 +1,12 @@
|
||||||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use crate::fmt_errors::format_js_error;
|
|
||||||
use crate::fs_util::canonicalize_path;
|
use crate::fs_util::canonicalize_path;
|
||||||
|
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::error::JsError;
|
use deno_core::error::JsError;
|
||||||
use deno_core::futures::Future;
|
use deno_core::futures::Future;
|
||||||
|
use deno_runtime::fmt_errors::format_js_error;
|
||||||
use log::info;
|
use log::info;
|
||||||
use notify::event::Event as NotifyEvent;
|
use notify::event::Event as NotifyEvent;
|
||||||
use notify::event::EventKind;
|
use notify::event::EventKind;
|
||||||
|
|
|
@ -15,7 +15,6 @@ mod emit;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod file_fetcher;
|
mod file_fetcher;
|
||||||
mod file_watcher;
|
mod file_watcher;
|
||||||
mod fmt_errors;
|
|
||||||
mod fs_util;
|
mod fs_util;
|
||||||
mod graph_util;
|
mod graph_util;
|
||||||
mod http_cache;
|
mod http_cache;
|
||||||
|
@ -67,7 +66,6 @@ use crate::cache::TypeCheckCache;
|
||||||
use crate::emit::TsConfigType;
|
use crate::emit::TsConfigType;
|
||||||
use crate::file_fetcher::File;
|
use crate::file_fetcher::File;
|
||||||
use crate::file_watcher::ResolutionResult;
|
use crate::file_watcher::ResolutionResult;
|
||||||
use crate::fmt_errors::format_js_error;
|
|
||||||
use crate::graph_util::graph_lock_or_exit;
|
use crate::graph_util::graph_lock_or_exit;
|
||||||
use crate::graph_util::graph_valid;
|
use crate::graph_util::graph_valid;
|
||||||
use crate::proc_state::ProcState;
|
use crate::proc_state::ProcState;
|
||||||
|
@ -89,6 +87,7 @@ use deno_core::serde_json::json;
|
||||||
use deno_core::v8_set_flags;
|
use deno_core::v8_set_flags;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_runtime::colors;
|
use deno_runtime::colors;
|
||||||
|
use deno_runtime::fmt_errors::format_js_error;
|
||||||
use deno_runtime::permissions::Permissions;
|
use deno_runtime::permissions::Permissions;
|
||||||
use deno_runtime::tokio_util::run_local;
|
use deno_runtime::tokio_util::run_local;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
use crate::args::Flags;
|
use crate::args::Flags;
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use crate::file_fetcher::get_source_from_data_url;
|
use crate::file_fetcher::get_source_from_data_url;
|
||||||
use crate::fmt_errors::format_js_error;
|
|
||||||
use crate::ops;
|
use crate::ops;
|
||||||
use crate::proc_state::ProcState;
|
use crate::proc_state::ProcState;
|
||||||
use crate::version;
|
use crate::version;
|
||||||
|
@ -25,6 +24,7 @@ use deno_graph::source::Resolver;
|
||||||
use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel;
|
use deno_runtime::deno_broadcast_channel::InMemoryBroadcastChannel;
|
||||||
use deno_runtime::deno_tls::rustls_pemfile;
|
use deno_runtime::deno_tls::rustls_pemfile;
|
||||||
use deno_runtime::deno_web::BlobStore;
|
use deno_runtime::deno_web::BlobStore;
|
||||||
|
use deno_runtime::fmt_errors::format_js_error;
|
||||||
use deno_runtime::permissions::Permissions;
|
use deno_runtime::permissions::Permissions;
|
||||||
use deno_runtime::permissions::PermissionsOptions;
|
use deno_runtime::permissions::PermissionsOptions;
|
||||||
use deno_runtime::worker::MainWorker;
|
use deno_runtime::worker::MainWorker;
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::args::LintFlags;
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use crate::file_watcher;
|
use crate::file_watcher;
|
||||||
use crate::file_watcher::ResolutionResult;
|
use crate::file_watcher::ResolutionResult;
|
||||||
use crate::fmt_errors;
|
|
||||||
use crate::fs_util::collect_files;
|
use crate::fs_util::collect_files;
|
||||||
use crate::fs_util::is_supported_ext;
|
use crate::fs_util::is_supported_ext;
|
||||||
use crate::fs_util::specifier_to_file_path;
|
use crate::fs_util::specifier_to_file_path;
|
||||||
|
@ -29,6 +28,7 @@ use deno_lint::linter::Linter;
|
||||||
use deno_lint::linter::LinterBuilder;
|
use deno_lint::linter::LinterBuilder;
|
||||||
use deno_lint::rules;
|
use deno_lint::rules;
|
||||||
use deno_lint::rules::LintRule;
|
use deno_lint::rules::LintRule;
|
||||||
|
use deno_runtime::fmt_errors::format_location;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use log::info;
|
use log::info;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
@ -382,7 +382,7 @@ impl LintReporter for PrettyLintReporter {
|
||||||
&source_lines,
|
&source_lines,
|
||||||
d.range.clone(),
|
d.range.clone(),
|
||||||
d.hint.as_ref(),
|
d.hint.as_ref(),
|
||||||
&fmt_errors::format_location(&JsStackFrame::from_location(
|
&format_location(&JsStackFrame::from_location(
|
||||||
Some(d.filename.clone()),
|
Some(d.filename.clone()),
|
||||||
Some(d.range.start.line_index as i64 + 1), // 1-indexed
|
Some(d.range.start.line_index as i64 + 1), // 1-indexed
|
||||||
// todo(#11111): make 1-indexed as well
|
// todo(#11111): make 1-indexed as well
|
||||||
|
|
|
@ -10,7 +10,6 @@ use crate::display;
|
||||||
use crate::file_fetcher::File;
|
use crate::file_fetcher::File;
|
||||||
use crate::file_watcher;
|
use crate::file_watcher;
|
||||||
use crate::file_watcher::ResolutionResult;
|
use crate::file_watcher::ResolutionResult;
|
||||||
use crate::fmt_errors::format_js_error;
|
|
||||||
use crate::fs_util::collect_specifiers;
|
use crate::fs_util::collect_specifiers;
|
||||||
use crate::fs_util::is_supported_test_ext;
|
use crate::fs_util::is_supported_test_ext;
|
||||||
use crate::fs_util::is_supported_test_path;
|
use crate::fs_util::is_supported_test_path;
|
||||||
|
@ -34,6 +33,7 @@ use deno_core::parking_lot::Mutex;
|
||||||
use deno_core::url::Url;
|
use deno_core::url::Url;
|
||||||
use deno_core::ModuleSpecifier;
|
use deno_core::ModuleSpecifier;
|
||||||
use deno_graph::ModuleKind;
|
use deno_graph::ModuleKind;
|
||||||
|
use deno_runtime::fmt_errors::format_js_error;
|
||||||
use deno_runtime::ops::io::Stdio;
|
use deno_runtime::ops::io::Stdio;
|
||||||
use deno_runtime::ops::io::StdioPipe;
|
use deno_runtime::ops::io::StdioPipe;
|
||||||
use deno_runtime::permissions::Permissions;
|
use deno_runtime::permissions::Permissions;
|
||||||
|
|
|
@ -11,6 +11,7 @@ use deno_core::Extension;
|
||||||
use deno_core::ModuleId;
|
use deno_core::ModuleId;
|
||||||
use deno_graph::source::ResolveResponse;
|
use deno_graph::source::ResolveResponse;
|
||||||
use deno_runtime::colors;
|
use deno_runtime::colors;
|
||||||
|
use deno_runtime::fmt_errors::format_js_error;
|
||||||
use deno_runtime::ops::worker_host::CreateWebWorkerCb;
|
use deno_runtime::ops::worker_host::CreateWebWorkerCb;
|
||||||
use deno_runtime::ops::worker_host::WorkerEventCb;
|
use deno_runtime::ops::worker_host::WorkerEventCb;
|
||||||
use deno_runtime::permissions::Permissions;
|
use deno_runtime::permissions::Permissions;
|
||||||
|
@ -24,7 +25,6 @@ use crate::args::DenoSubcommand;
|
||||||
use crate::checksum;
|
use crate::checksum;
|
||||||
use crate::compat;
|
use crate::compat;
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
use crate::fmt_errors::format_js_error;
|
|
||||||
use crate::module_loader::CliModuleLoader;
|
use crate::module_loader::CliModuleLoader;
|
||||||
use crate::node;
|
use crate::node;
|
||||||
use crate::npm::NpmPackageReference;
|
use crate::npm::NpmPackageReference;
|
||||||
|
|
|
@ -189,6 +189,7 @@ fn format_js_error_inner(js_error: &JsError, is_child: bool) -> String {
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Format a [`JsError`] for terminal output.
|
||||||
pub fn format_js_error(js_error: &JsError) -> String {
|
pub fn format_js_error(js_error: &JsError) -> String {
|
||||||
format_js_error_inner(js_error, false)
|
format_js_error_inner(js_error, false)
|
||||||
}
|
}
|
|
@ -19,6 +19,7 @@ pub use deno_webstorage;
|
||||||
|
|
||||||
pub mod colors;
|
pub mod colors;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
pub mod fmt_errors;
|
||||||
pub mod fs_util;
|
pub mod fs_util;
|
||||||
pub mod inspector_server;
|
pub mod inspector_server;
|
||||||
pub mod js;
|
pub mod js;
|
||||||
|
|
Loading…
Reference in a new issue