Ever forget to open the console window while developing JavaScript? I know it's a cardinal sin, but once and a while I forget. I'm human.
I wondered: can I use window.onerror to let me know that there are JavaScript runtime errors, in case I forget to open the console?
I could use an alert() box, but those are obtrusive and annoying.
Then I then thought of using Toaster. It's a great library that flashes a message in a preconfigured corner of the window. The message briefly appears before going away.
Angular-Errors-On-Toast is my Angular module solution.
Will my end users see these messages? No. It's configured to display these errors only when the domain is localhost. I'll make this configurable in the future. You can modify the source code in the meantime.- bower install angular-errors-on-toast#0.1
- Change exceptionHandler.js
I.e.:
angular.module("app1").factory("$exceptionHandler", function ($injector) {
...
});
In errorsOnToast.js, change the array of allowedURLs to have the correct URL(s). I.e.:
var allowedUrls = ["localhost", "example.com"];
- Angular 1.3
- angular-toastr 0.1
![alt tag](https://raw.githubusercontent.com/joehoppe/angular-errors-on-toast/master/readme/error.PNG) MIT
I can do a lot more with this. Please let me know if you are interested.