简体   繁体   中英

Angular displays url encoded errors, how to get decoded version?

When I have uncaught errors in my angular applications the console message looks like this:

Error: [$injector:modulerr] http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=app&p1=%5B%24injector%3Aunpr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.4.3%2F%24injector%2Funpr%3Fp0%3DENVIRONMENT%0AJ%2F%3C%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A11%3A416%0Aeb%2Fr.%24injector%3C%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A45%3A375%0Ad%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A43%3A364%0A%40http%3A%2F%2Flocalhost%3A8600%2Fapp%2Fapp.js%3A42%3A18%0Ae%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A44%3A154%0Ad%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A42%3A320%0Ag%2F%3C%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A42%3A452%0Am%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A12%3A320%0Ag%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A42%3A229%0Aeb%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A45%3A1%0AAc%2Fd%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A24%3A339%0AAc%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A25%3A151%0AZd%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A23%3A464%0A%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A294%3A428%0An.Callbacks%2Fj%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A2%3A26920%0An.Callbacks%2Fk.fireWith%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A2%3A27738%0A.ready%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A2%3A29530%0AI%40http%3A%2F%2Flocalhost%3A8600%2Flibs.js%3A2%3A29721%0AnrWrapper%40http%3A%2F%2Flocalhost%3A8600%2F%23%2Fdashboard%3A15%3A12749%0A

Which is not useful, but if I url_decode it it is much better, like this:

http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=app&p1=[$injector:unpr] http://errors.angularjs.org/1.4.3/$injector/unpr?p0=ENVIRONMENT
J/<@http://localhost:8600/libs.js:11:416
eb/r.$injector<@http://localhost:8600/libs.js:45:375
d@http://localhost:8600/libs.js:43:364
@http://localhost:8600/app/app.js:42:18
e@http://localhost:8600/libs.js:44:154
d@http://localhost:8600/libs.js:42:320
g/<@http://localhost:8600/libs.js:42:452
m@http://localhost:8600/libs.js:12:320
g@http://localhost:8600/libs.js:42:229
eb@http://localhost:8600/libs.js:45:1
Ac/d@http://localhost:8600/libs.js:24:339
Ac@http://localhost:8600/libs.js:25:151
Zd@http://localhost:8600/libs.js:23:464
@http://localhost:8600/libs.js:294:428
n.Callbacks/j@http://localhost:8600/libs.js:2:26920
n.Callbacks/k.fireWith@http://localhost:8600/libs.js:2:27738
.ready@http://localhost:8600/libs.js:2:29530
I@http://localhost:8600/libs.js:2:29721
nrWrapper@http://localhost:8600/#/dashboard:15:12749

How can I get angular to output errors this way by default? Thanks.

It's url encoded because it's a link. Click it! :D

It will bring you to a webpage that explains the error.

This is your error

If you go to that page and look at the error it will say that it threw an error because of x error. Then that error will be a link to , so click that as well.

And now that you've gotten to that last page, the error is that you have an unknown provider called ENVIRONMENT.

You can override exception handler:

angular.module('exceptionOverride', []).factory('$exceptionHandler', function() {
  return function(exception, cause) {
    exception.message += ' (caused by "' + cause + '")';
    throw exception;
  };
});

More here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM