computmaxer / karma-jspm

Other
74 stars 50 forks source link

A longer stack trace access on error on System.import #19

Open douglasduteil opened 10 years ago

douglasduteil commented 10 years ago

Hi

When files fail to be imported there is no information about the file path on the stack trace from the adapter. I usually gat :

Chrome 38.0.2125 (Linux) ERROR
  Uncaught ReferenceError: foo is not defined
  at /home/x/tmp/karma-jspm/src/adapter.js:47

It would be better to access to the it on the stack

Chrome 38.0.2125 (Linux) ERROR
  Uncaught ReferenceError: foo is not defined
  at /home/x/tmp/karma-jspm/src/adapter.js:47
  at Function.<anonymous> (http://localhost:9876/base/src/foo.js:3:20)

Any idea how to do it ?

douglasduteil commented 10 years ago

Following https://github.com/Workiva/karma-jspm/commit/85afadbe75bce0fd7069224c8065d99d6a663a2f

I end up console the error stack to have the full stack trace

var promise = System.import(extractModuleName(modulePath))
  .catch(function(e){
-     setTimeout(function() {
-         throw e;
+         console.error(e.stack);
-    });
  });
Chrome 38.0.2125 (Linux) ERROR: 'ReferenceError: foo is not defined
    at Function.<anonymous> (http://localhost:9876/base/src/foo.js:3:20)
    at c.execute (http://localhost:9876/base/jspm_packages/system.js?1dc2a0b7ae6fe87e133998aa99635a8ce188d3db:1:12908)
    at c (http://localhost:9876/base/jspm_packages/system.js?1dc2a0b7ae6fe87e133998aa99635a8ce188d3db:1:4844)
    at c (http://localhost:9876/base/jspm_packages/system.js?1dc2a0b7ae6fe87e133998aa99635a8ce188d3db:1:4806)
    at l (http://localhost:9876/base/jspm_packages/system.js?1dc2a0b7ae6fe87e133998aa99635a8ce188d3db:1:3563)
    at Object.execute (http://localhost:9876/base/jspm_packages/system.js?1dc2a0b7ae6fe87e133998aa99635a8ce188d3db:1:6886)
    at o (http://localhost:9876/base/jspm_packages/es6-module-loader.js?e05b384351da26afa1fddb98eab722d0e5651005:7:17576)
    at j (http://localhost:9876/base/jspm_packages/es6-module-loader.js?e05b384351da26afa1fddb98eab722d0e5651005:7:15533)
    at k (http://localhost:9876/base/jspm_packages/es6-module-loader.js?e05b384351da26afa1fddb98eab722d0e5651005:7:15881)
    at http://localhost:9876/base/jspm_packages/es6-module-loader.js?e05b384351da26afa1fddb98eab722d0e5651005:7:14443'

Chrome 38.0.2125 (Linux) Foo should do the thing FAILED
    TypeError: Cannot read property 'module' of undefined
        at Object.<anonymous> (/home/x/xxx/bar/src/foo.spec.js:14:19)
    TypeError: Cannot read property 'href' of undefined
        at Object.<anonymous> (/home/x/xxx/bar/src/foo.spec.js:29:22)

What you think ?