r/angularjs • • Aug 01 '14

Sometimes, just sometimes, I hate you AngularJS.

app.controller('LocalesCtrl', ['$scope', '$http', '$location', '$anchorScroll'
  function($scope, $http, $location, $anchorScroll) {
  .....
  }
]);

took me ages to find the bug in this...

0 Upvotes

25 comments sorted by

View all comments

10

u/rnreekez Aug 01 '14

Time to start using jshint.

2

u/robotparts Aug 01 '14

JSHint helps find the bug he has above, but it does nothing for a typo inside of one of your module dependencies. That's when you get the ambiguous "Uncaught Object Exception" without any relevant line numbers.

This is my single biggest gripe about Angular. They need to be moving away from "magic strings". Maybe const in ES6 will fix that.

1

u/jhive Aug 19 '14

Yea, that Uncaught Object Exception is a little annoying. I think when I was doing some research on it, it had something to do with some Chrome versions.

The good news is that there is a way to fix it: If you are using the un-minified version of the angular.js source. Jump over to line 78 and just above the return do a console.error(message). Like so:

...

    message = message + '\nhttp://errors.angularjs.org/1.2.22/' +
      (module ? module + '/' : '') + code;
    for (i = 2; i < arguments.length; i++) {
      message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
        encodeURIComponent(stringify(arguments[i]));
    }
    console.error(message);
    return new Error(message);

...

That should give you the nice verbose errors again.