Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Readable Angular.js Errors?

Angular.js does not provide human-readable error messages by default.

Is there anyway to change the default, cryptic Angular.js exception URL to a more readable error message? As it is, I have to copy the URL, remove the prefix, and paste in the browser to see what the problem is.

For example, transforming the following exception to a more useful error message:

Error: [ng:areq] http://errors.angularjs.org/1.3.0/ng/areq?p0=InterfaceController&p1=not%20a%20function%2C%20got%20undefined y/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular....

To something like:

"Missing required argument to InterfaceController"

I know I can provide my own exception handler:

.factory('$exceptionHandler', function () {
  return function errorCatcherHandler(exception, cause) {
    console.error(exception);
  };
});

Am I approaching this wrong?

like image 853
Xeoncross Avatar asked Oct 22 '14 16:10

Xeoncross


2 Answers

The problem was that I was developing against the minified/compressed version (assuming it was like other JS libraries). The uncompressed version includes a readable error message.

https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js
https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js
like image 53
Xeoncross Avatar answered Sep 21 '22 16:09

Xeoncross


If you want to have readable error in your console, use non-minified version of angular libraries

--

To know what your current error is : copy those link and paste them in browser it will take you to the page where you can read more details about that particular error.

I pasted your error in browser url and i got

 Error: error:areq Bad Argument
 Argument 'InterfaceController' is not a function, got undefined 
like image 41
harishr Avatar answered Sep 22 '22 16:09

harishr