Angular module that displays JavaScript window.onerror errors to the end user using toastr. Only displays the message if the URL is localhost, so that it doesn't impact your QA or production users.

Module License: MIT

Added by: Sam Deering





Stars: 2

Watchers: 2

Forks: 0

Module Description


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.

How to get it

  1. bower install angular-errors-on-toast#0.1
  2. Change exceptionHandler.js

How to set it up

Replace "app" with the name of your AngularJS application. If you have more than one, duplicate the code multiple times. I.e.: ``` angular.module("app1").factory("$exceptionHandler", function ($injector) { ... }); angular.module("app2").factory("$exceptionHandler", function ($injector) { ... }); ```

Want the app to work for a URL other than localhost?

In errorsOnToast.js, change the array of allowedURLs to have the correct URL(s). I.e.:

var allowedUrls = ["localhost", ""];


  1. Angular 1.3
  2. angular-toastr 0.1

What does it look like?

This briefly flashes in the corner of the window before going away.
![alt tag](



I can do a lot more with this. Please let me know if you are interested.

Module stats last updated: 2015-06-28 11:03:03

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!