Skip to content
This repository

wrong stack trace #10

Open
wants to merge 1 commit into from

1 participant

Chris Thorn
Chris Thorn

Hi —

Working with dnode, I commonly run into an error where I get the "wrong" stack trace. I can reproduce it pretty easily, by editing one of the examples in the repo.

    window.onload = function () {
        DNode.connect(function (remote) {
            remote.cat(function (says) {
                throw 42;
            });
        });
    };

In the console, instead of seeing a useful stack trace, I see:

Error: Uncaught, unspecified 'error' event. (http://d.pr/MchA) Worse, the line number is wrong. (meaning, it is not the line that's responsible for throwing the error.)

This can be annoying, especially when one is working on a project that's less trivial, because one has no idea what line number actually threw the error.

Poking around, I found out that the two try/catch statements in dnode-protocol we actually responsible for masking the line number for the error. My instinct tells me that those try/catch are there for a good reason, but (at least during active development), I want to know where my errors are coming from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 2 additions and 4 deletions. Show diff stats Hide diff stats

  1. 6  index.js
6  index.js
@@ -78,8 +78,7 @@ var Session = exports.Session = function (id, wrapper) {
78 78
             return;
79 79
         }
80 80
         
81  
-        try { self.handle(msg) }
82  
-        catch (err) { self.emit('error', err) }
  81
+        self.handle(msg);
83 82
     };
84 83
     
85 84
     self.handle = function (req) {
@@ -140,8 +139,7 @@ var Session = exports.Session = function (id, wrapper) {
140 139
     }
141 140
     
142 141
     function apply(f, obj, args) {
143  
-        try { f.apply(obj, args) }
144  
-        catch (err) { self.emit('error', err) }
  142
+        f.apply(obj, args);
145 143
     }
146 144
     
147 145
     return self;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.