Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get more verbose error info in Angular?

I get only this error text in Chrome. No any additional info:

enter image description here

What does it mean? What happened? Is there a way to tell Angular or Chrome to show more verbose error information?

Here is my app.js file. Nothing else is included:

'use strict';


// Declare app level module which depends on filters, and services

var vsApp = angular.module('vsApp', [
    'ngRoute',
    'vsApp.filters',
    'vsApp.services',
    'vsApp.directives',
    'vsApp.controllers'
]);

vsApp.config(["$routeProvider"], function($routeProvider) {
    $routeProvider.when('/registration', {templateUrl: 'partials/reg.html', controller: 'regCtrl'});
    $routeProvider.when('/login', {templateUrl: 'partials/login.html', controller: 'loginCtrl'});
    $routeProvider.otherwise({redirectTo: '/'});
});

vsApp.controller("regCtrl", function() {});
vsApp.controller("loginCtrl", function() {});

ng-app attribute inclusion:

<!DOCTYPE html>
<html ng-app="vsApp">

My <head> tag:

<script id="angularScript" src="/bower_components/angular/angular.js"></script>
<script src="/bower_components/angular-route/angular-route.js"></script>
<script src="/assets/js/app.js"></script>

UPD:

Protractor brought more info:

   Message:
     UnknownError: unknown error: [$injector:modulerr] Failed to instantiate module vsApp due to:
Error: [ng:areq] Argument 'fn' is not a function, got string
http://errors.angularjs.org/1.3.0-build.2795+sha.222d473/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20string
    at http://localhost:3000/bower_components/angular/angular.js:78:12
    at assertArg (http://localhost:3000/bower_components/angular/angular.js:1583:11)
    at assertArgFn (http://localhost:3000/bower_components/angular/angular.js:1593:3)
    at annotate (http://localhost:3000/bower_components/angular/angular.js:3318:5)
    at Object.invoke (http://localhost:3000/bower_components/angular/angular.js:3986:21)
    at runInvokeQueue (http://localhost:3000/bower_components/angular/angular.js:3915:35)
    at http://localhost:3000/bower_components/angular/angular.js:3924:11
    at Array.forEach (native)
    at forEach (http://localhost:3000/bower_components/angular/angular.js:320:11)
    at loadModules (http://localhost:3000/bower_components/angular/angular.js:3905:5)
like image 304
Green Avatar asked Jun 06 '14 09:06

Green


1 Answers

I don't know how to get more verbose error messages. I don't think it is even possible. However, you seem to have a at least a syntax error:

vsApp.config(["$routeProvider", function($routeProvider) {
   /* notice the [ ] */
}]);

because you're using annotated injection of dependencies, just like in the documentation: https://docs.angularjs.org/guide/providers#providers_provider-recipe

myApp.config(["unicornLauncherProvider", function(unicornLauncherProvider) {
  unicornLauncherProvider.useTinfoilShielding(true);
}]);

In any case I tried to reproduce the error message you got but I only obtain useful error messages. see http://jsfiddle.net/CE6j9/1/

Uncaught Error: [$injector:modulerr] Failed to instantiate module vsApp due to:
Error: [ng:areq] Argument 'fn' is not a function, got string
http://errors.angularjs.org/1.2.1/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20string
at http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:78:12
at assertArg (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:1346:11)
at assertArgFn (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:1356:3)
at annotate (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:2926:5)
at Object.invoke (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:3587:21)
at http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:3534:37
at Array.forEach (native)
at forEach (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:300:11)
at loadModules (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:3521:5)
at createInjector (http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.js:3461:11)
http://errors.angularjs.org/1.2.1/$injector/modulerr?p0=vsApp&p1=Error%3A%2…cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.2.1%2Fangular.js%3A3461%3A11)
http://errors.angularjs.org/1.2.1/$injector/modulerr?p0=vsApp&p1=Error%3A%2…cloudflare.com%2Fajax%2Flibs%2Fangular.js%2F1.2.1%2Fangular.js%3A3461%3A11)     angular.js:78
(anonymous function) angular.js:78
(anonymous function) angular.js:3555
forEach angular.js:300
loadModules angular.js:3521
createInjector angular.js:3461
doBootstrap angular.js:1282
bootstrap angular.js:1297
angularInit angular.js:1246
(anonymous function) angular.js:20126
trigger angular.js:2298
(anonymous function) angular.js:2562
forEach angular.js:300
eventHandler 

maybe you had something else interfering? I got the lower half of errors (with line numberS) when I clicked in the arrow. maybe you have the wrong settings in chrome?

like image 85
Eduard Gamonal Avatar answered Oct 27 '22 01:10

Eduard Gamonal