summaryrefslogtreecommitdiff
path: root/cli/source_maps.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/source_maps.rs')
-rw-r--r--cli/source_maps.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/cli/source_maps.rs b/cli/source_maps.rs
index 9f57814d4..70b9faac6 100644
--- a/cli/source_maps.rs
+++ b/cli/source_maps.rs
@@ -1,5 +1,8 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-//! This mod provides functions to remap a deno_core::deno_core::JsError based on a source map
+
+//! This mod provides functions to remap a `JsError` based on a source map.
+
+use deno_core::error::JsError as CoreJsError;
use sourcemap::SourceMap;
use std::collections::HashMap;
use std::str;
@@ -18,13 +21,13 @@ pub trait SourceMapGetter {
/// find a SourceMap.
pub type CachedMaps = HashMap<String, Option<SourceMap>>;
-/// Apply a source map to a deno_core::JsError, returning a JsError where file
-/// names and line/column numbers point to the location in the original source,
-/// rather than the transpiled source code.
+/// Apply a source map to a `deno_core::JsError`, returning a `JsError` where
+/// file names and line/column numbers point to the location in the original
+/// source, rather than the transpiled source code.
pub fn apply_source_map<G: SourceMapGetter>(
- js_error: &deno_core::JsError,
+ js_error: &CoreJsError,
getter: &G,
-) -> deno_core::JsError {
+) -> CoreJsError {
// Note that js_error.frames has already been source mapped in
// prepareStackTrace().
let mut mappings_map: CachedMaps = HashMap::new();
@@ -67,7 +70,7 @@ pub fn apply_source_map<G: SourceMapGetter>(
_ => js_error.source_line.clone(),
};
- deno_core::JsError {
+ CoreJsError {
message: js_error.message.clone(),
source_line,
script_resource_name,
@@ -194,7 +197,7 @@ mod tests {
#[test]
fn apply_source_map_line() {
- let e = deno_core::JsError {
+ let e = CoreJsError {
message: "TypeError: baz".to_string(),
source_line: Some("foo".to_string()),
script_resource_name: Some("foo_bar.ts".to_string()),