summaryrefslogtreecommitdiff
path: root/src/js_errors.rs
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-01-12 06:14:09 -0800
committerRyan Dahl <ry@tinyclouds.org>2019-01-12 09:14:09 -0500
commite29a676b78773ddbb095a41eaf4f2ce5a8a701ab (patch)
treebb79f5bd54db2c0d8d2ae8011543f90087e428e7 /src/js_errors.rs
parent6322f45e7b11eb0124bcf63b679b4db05f1acdb6 (diff)
Avoid show confusing lines in gen/bundle/main.js that throws error (#1502)
Diffstat (limited to 'src/js_errors.rs')
-rw-r--r--src/js_errors.rs35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/js_errors.rs b/src/js_errors.rs
index fae649609..905dcefbd 100644
--- a/src/js_errors.rs
+++ b/src/js_errors.rs
@@ -75,28 +75,31 @@ impl ToString for StackFrame {
impl ToString for JSError {
fn to_string(&self) -> String {
- // TODO use fewer clones.
// TODO Improve the formatting of these error messages.
let mut s = String::new();
if self.script_resource_name.is_some() {
- s.push_str(&self.script_resource_name.clone().unwrap());
- }
- if self.line_number.is_some() {
- s.push_str(&format!(
- ":{}:{}",
- self.line_number.unwrap(),
- self.start_column.unwrap()
- ));
- assert!(self.start_column.is_some());
- }
- if self.source_line.is_some() {
- s.push_str("\n");
- s.push_str(&self.source_line.clone().unwrap());
- s.push_str("\n\n");
+ let script_resource_name = self.script_resource_name.as_ref().unwrap();
+ // Avoid showing internal code from gen/bundle/main.js
+ if script_resource_name != "gen/bundle/main.js" {
+ s.push_str(script_resource_name);
+ if self.line_number.is_some() {
+ s.push_str(&format!(
+ ":{}:{}",
+ self.line_number.unwrap(),
+ self.start_column.unwrap()
+ ));
+ assert!(self.start_column.is_some());
+ }
+ if self.source_line.is_some() {
+ s.push_str("\n");
+ s.push_str(self.source_line.as_ref().unwrap());
+ s.push_str("\n\n");
+ }
+ }
}
- s.push_str(&self.message.clone());
+ s.push_str(&self.message);
for frame in &self.frames {
s.push_str("\n");