Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't see errors from angular #1374

Closed
pocesar opened this issue Jul 24, 2016 · 7 comments
Closed

can't see errors from angular #1374

pocesar opened this issue Jul 24, 2016 · 7 comments

Comments

@pocesar
Copy link

pocesar commented Jul 24, 2016

I'm using JSPM, but it's a problem with SystemJS.

I'm doing a refactor on my code to use System output from Typescript, and so far, I'm trying to blindly trying to fix errors that are appearing because SystemJS seems to be swallowing the error message from angular.

systemjs

load.js is:

(function(){
    var paths = ["/javascripts/checker/main.js","/javascripts/app/main.js"];

    function importNext () {
        var path = paths.shift();
        if (path) {
            System.import(path).then(importNext, function(err){
                console.warn(path);
                console.log(err);
                importNext();
            })
        } else {
            console.log('loaded');
        }
    }

    importNext();
})()

How can I see the original exception?

@pocesar
Copy link
Author

pocesar commented Jul 24, 2016

Ok, I couldn't find anywhere in the docs about originalErr, but found it using the browser debugger, so I'm just leaving this here to help people having the same issue:

System.import(path).then(importNext, function(err){
                console.warn(path);
                console.log(err.originalErr);
                importNext();
            })

@guybedford
Copy link
Member

What specific error is this? If you can share a replication it would be really useful to understand how SystemJS is obscuring the original message and if there is a better way to pick up the original message in https://github.com/ModuleLoader/es6-module-loader/blob/master/src/wrapper-start.js#L41 to avoid it.

@pocesar
Copy link
Author

pocesar commented Jul 25, 2016

alright:

  • System.import('app/main')
  • app/main.js calls import * as Base from './modules/base';
  • modules/base.js calls import * as angular from 'angular'
  • modules/base.js tries to load a non-yet-loaded angular module, through angular.module('Base', ['NotYet'])
  • app/main.js calls angular.module('Main', ['Base']) and angular.bootstrap(document, ['Main'])
  • it fails "silently", it shows the minErr, but with no message from angular.

@guybedford
Copy link
Member

@pocesar I've completely forgotten how to use Angular here, so can you perhaps suggest how to make the following code give an error that covers your use case? I just tried the following:

    SystemJS.import('angular').then(function(angular) {
      angular.module('myModule', ['not-existing']).
      config(function(injectables) {
      }).
      run(function(injectables) {
      });
      console.log('done?');
    });

but get no errors.

@pocesar
Copy link
Author

pocesar commented Jul 25, 2016

@guybedford my files are SystemJS modules with anonymous register calls (generated from Typescript). You'd have to wrap the code before trying haha

// app/main.js
System.register(['angular', '../modules/base'], function(exports_1, context_1) {
    'use strict';
    var __moduleName = context_1 && context_1.id;
    var angular;
    return {
        setters:[
            function (angular_1) {
                angular = angular_1;
            },
            function (_1) {}],
        execute: function() {
            angular
                .module('Main', [
                'Base',
                'Client'
            ]);
            angular.bootstrap(document, ['Main']);
        }
    }
});
// modules/base.js
System.register(['angular'], function(exports_1, context_1) {
    'use strict';
    var __moduleName = context_1 && context_1.id;
    var angular;
    return {
        setters:[
            function (angular_1) {
                angular = angular_1;
            }],
        execute: function() {
            angular
                .module('Base', [
                'NonExistant',
            ]);
        }
    }
});
// load.js
 System.import('app/main.js').then(console.log.bind(console), function(err){
                console.warn(path);
                console.log(err);
            })

@guybedford
Copy link
Member

Thanks for clarifying. Fixed in ModuleLoader/es-module-loader@07aa567.

@guybedford
Copy link
Member

Released in 0.19.34.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants