summaryrefslogtreecommitdiff
path: root/cli/fmt_errors.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-11-19 20:37:22 +0100
committerGitHub <noreply@github.com>2020-11-19 20:37:22 +0100
commite582796f42b96a940cba757a8a08573bc61aca0c (patch)
tree66796ba77c195359fc61d149fe3de55dd593afaa /cli/fmt_errors.rs
parent9eaa1fb71d03679367ebca0e0361fa0e47a1274f (diff)
refactor(cli): rename fmt_errors::JsError to PrettyJsError (#8435)
This commit renames "fmt_errors::JsError" to "PrettyJsError" to avoid confusion with "deno_core::JsError". Consequently "CoreJsError" aliases to "deno_core::JsError" were removed. Additionally source mapping step has been removed from "PrettyJsError::create" to better separate domains.
Diffstat (limited to 'cli/fmt_errors.rs')
-rw-r--r--cli/fmt_errors.rs30
1 files changed, 12 insertions, 18 deletions
diff --git a/cli/fmt_errors.rs b/cli/fmt_errors.rs
index 890f9b83f..b3c855db9 100644
--- a/cli/fmt_errors.rs
+++ b/cli/fmt_errors.rs
@@ -1,13 +1,10 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
//! This mod provides DenoError to unify errors across Deno.
use crate::colors;
-use crate::source_maps::apply_source_map;
-use crate::source_maps::SourceMapGetter;
-use deno_core::error::{AnyError, JsError as CoreJsError, JsStackFrame};
+use deno_core::error::{AnyError, JsError, JsStackFrame};
use std::error::Error;
use std::fmt;
use std::ops::Deref;
-use std::sync::Arc;
const SOURCE_ABBREV_THRESHOLD: usize = 150;
@@ -231,29 +228,26 @@ fn format_maybe_source_line(
format!("\n{}{}\n{}{}", indent, source_line, indent, color_underline)
}
-/// Wrapper around deno_core::JsError which provides color to_string.
+/// Wrapper around deno_core::JsError which provides colorful
+/// string representation.
#[derive(Debug)]
-pub struct JsError(CoreJsError);
+pub struct PrettyJsError(JsError);
-impl JsError {
- pub fn create(
- core_js_error: CoreJsError,
- source_map_getter: Arc<impl SourceMapGetter>,
- ) -> AnyError {
- let core_js_error = apply_source_map(&core_js_error, source_map_getter);
- let js_error = Self(core_js_error);
- js_error.into()
+impl PrettyJsError {
+ pub fn create(js_error: JsError) -> AnyError {
+ let pretty_js_error = Self(js_error);
+ pretty_js_error.into()
}
}
-impl Deref for JsError {
- type Target = CoreJsError;
+impl Deref for PrettyJsError {
+ type Target = JsError;
fn deref(&self) -> &Self::Target {
&self.0
}
}
-impl fmt::Display for JsError {
+impl fmt::Display for PrettyJsError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut frames = self.0.frames.clone();
@@ -290,7 +284,7 @@ impl fmt::Display for JsError {
}
}
-impl Error for JsError {}
+impl Error for PrettyJsError {}
#[cfg(test)]
mod tests {