Xeoncross
Xeoncross

Reputation: 57184

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?

Upvotes: 12

Views: 2465

Answers (2)

harishr
harishr

Reputation: 18055

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 

Upvotes: 3

Xeoncross
Xeoncross

Reputation: 57184

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

Upvotes: 17

Related Questions